#include <bits/stdc++.h>
using namespace std;
long long n, k, p, ans, last = 0;
long long a[10101000];
map<long long, long long> num;
signed main() {
  scanf("%lld %lld", &n, &k);
  p = (1 << k) - 1;
  num[0] = 1;
  for (long long i = 1, x; i <= n; i++) scanf("%lld", &a[i]);
  ans = (n + 1) * n;
  ans /= 2;
  for (long long i = 1; i <= n; i++) {
    long long ans1 = last ^ a[i], ans2 = ans1 ^ p;
    if (num[ans1] > num[ans2])
      ans -= num[ans2]++, last = ans2;
    else
      ans -= num[ans1]++, last = ans1;
  }
  printf("%lld", ans);
  return 0;
}
