#include<iostream>
#include<vector>
using namespace std;
int curcnt[33];
bool possible(int x, int K, int N, vector<int> &A)
{
    fill(curcnt, curcnt + 32, 0);
    int curbit = 0;
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        int cur1 = A[i];
        int curbit = 0;
        while(cur1)
        {
            int bit = cur1 & 1;
            if(bit) curcnt[curbit]++;
            curbit++;
            cur1 = cur1>>1;
        }
        int temp = x;
        bool bl = true;
        curbit = 0;
        while(temp && bl)
        {
            int bit = temp & 1;
            if(bit)
            {
                if(curcnt[curbit] == 0) bl = false;
            }
            curbit++;
            temp = temp>>1;
        }
        curbit = 0;
        if(bl)
        {
            temp = x;
            while(temp)
            {
                int bit = temp & 1;
                if(bit) curcnt[curbit] = 0;
                curbit++;
                temp = temp>>1;
            }
            ans++;
        }
    }
    if(ans < K) return false;
    else return true;
}
int main()
{
    int N, K;
    cin>>N>>K;
    vector<int> A(N);
    int maxA = 0;
    for(int i = 0; i < N; i++) cin>>A[i];
    for(int i = 0; i < N; i++) maxA = max(maxA, A[i]);
    bool found = false;
    int ans = 0;
    int range = 2;
    if(maxA > 2) range = 2048;
    for(int i = 2048; i > 0 && !found; i--)
    {
        if(possible(i, K, N, A))
        {
            found = true;
            ans = i;
        }
    }
    cout<<ans<<"\n";
    return 0;
}
