#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n,t; scanf("%d%d",&n,&t); vector a(n); rep(i,n) scanf("%d",&a[i]); map curr,next; curr[t]=0; rep(i,n){ next.clear(); for(auto p:curr){ int x; lint v; x=p.first&a[i]; v=p.second+p.first-(p.first&a[i]); if(next.count(x)==0){ next[x]=v; } else{ next[x]=max(next[x],v); } x=p.first|a[i]; v=p.second+(p.first|a[i])-p.first; if(next.count(x)==0){ next[x]=v; } else{ next[x]=max(next[x],v); } } swap(curr,next); } lint ans=0; for(auto p:curr) ans=max(ans,p.second); printf("%lld\n",ans); return 0; }