#include #include #include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} template struct FenwickTree{ int n; vector bit; FenwickTree(int N){ bit.resize(N+1); n = N; } T sum(int i){ i++; T s = 0; while (i > 0){ s += bit[i]; i -= i & -i; } return s; } T sum(int l, int r){ if (l >= r) return 0; return sum(r-1) - sum(l-1); } void add(int i, T x){ i++; while (i <= n){ bit[i] += x; i += i & -i; } } }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; ll M; cin>>N>>M; vectorP(N); FenwickTreefw(N); ll cnt=0; for(int i=0;i>P[i]; P[i]--; cnt+=fw.sum(P[i],N); fw.add(P[i],1); } if(cnt==0)cout<<0<<"\n"; else if(cnt%2==0){ if(M%2==0)cout<