#include using namespace std; #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define rep(i,n,m) for(int i = (n); i < (int)(m); i++) #define rrep(i,n,m) for(int i = (m) - 1; i >= (int)(n); i--) using ll = long long; using ld = long double; const ll MOD1 = 1e9+7; const ll MOD9 = 998244353; const int INF = (int)1e9+1; template bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;} template bool chmax(T &a,T b){if(a vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; int main(){ int n,t; cin>>n>>t; vectora(n); rep(i,0,n)cin>>a[i]; vector>dp(n+1); dp[0][t]=0; rep(i,0,n){ auto ope=[&](pairpre,int cmd){ pairnxt=pre; if(cmd==0)nxt.first&=a[i]; else nxt.first|=a[i]; if(pre.firstnxt.first)nxt.second-=1; return nxt; }; for(auto p:dp[i]){ rep(j,0,2){ auto nxt=ope(p,j); if(dp[i+1].count(nxt.first))chmax(dp[i+1][nxt.first],nxt.second); else dp[i+1][nxt.first]=nxt.second; } } } int ret=-INF; for(auto p:dp[n])chmax(ret,p.second); cout<