#include <iostream>
#include <vector>
using namespace std;


int main()
{
    cin.tie(NULL);
    int N, K;
    int storage;
    int calc;
    bool Isempty = false;
    cin>>N>>K;
    int ar;
    K -= 1;
    for(int i = 0; i<N; i++){
        if (Isempty = (false)){
        calc = ar;
        Isempty = (true);}
    cin>>ar;
     calc = ar;
    calc = calc | ar;
    if(calc % K == 0){
        storage = storage & calc;
        storage = calc;
    }
   /* cout<<"Value of storage = "<<storage<<endl;
    cout<<"Value of calc = "<<calc<<endl;
    cout<<"Value of ar = "<<ar<<endl;*/
    }
    return 0;
}
