#include <iostream>
#include <vector>
using namespace std;
int n, k;
long long maxi_length = -1;
vector<long long> eagers;
int length_computer(long long x) {
	int amount = 0;
	while (x > 0) {
		x /= 2;
		amount++;
	}
	return amount;
}
bool works(long long x) {
	int amount = 0, current = 0;
	for (int i = 0; i < n; i++) {
		current = current | eagers[i];
		if (current >= x) {
			amount++;
			current = 0;
		}
	}
	if (amount >= k) {
		return true;
	}
	return false;
}
int main() {
	cin >> n >> k;
	eagers.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> eagers[i];
		int current = length_computer(eagers[i]);
		if (maxi_length == -1 || maxi_length < current) {
			maxi_length = current;
		}
	}
	if (works(3)) cout << 3 << "\n";
	else if (works(2)) cout << 2 << "\n";
	else if (works(1)) cout << 1 << "\n";
	else cout << 0 << "\n";
}