#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  char c;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>c;
      if(c=='1'){
        a[i]|=1<<j;
      }
    }
  }
  int64_t even=0,odd=0;
  for(int i=1;i<n;i++){
    if(__builtin_popcount(a[0]^a[i])%2==0)even++;
    else odd++;
  }
  cout<<odd+even*odd<<'\n';
}
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll> pql;
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef map<ll, ll> ml;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll quo(ll a, ll b) {return (a - mod(a, b)) / b;}
template <typename T, typename U> bool chmin(T &a, const U b) {if(a > b) {a = b; return 1;} return 0;}
template <typename T, typename U> bool chmax(T &a, const U b) {if(a < b) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e5;
const ld eps = 1e-9;
const char newl = '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll a, b;
  cin >> a >> b;
  ll c = min(a, b);
  vl ans;
  rep2(i, 1, c-1) {
    ans.push_back(i);
    ans.push_back(-i);
  }

  if(a < b) {
    ll tmp = 0;
    rep2(i, c, c+b-a) {
      tmp += i;
      ans.push_back(-i);
    }
    ans.push_back(tmp);
  }

  if(a == b) {
    ans.push_back(c);
    ans.push_back(-c);
  }

  if(a > b) {
    ll tmp = 0;
    rep2(i, c, c+a-b) {
      tmp += i;
      ans.push_back(i);
    }
    ans.push_back(-tmp);
  }

  for(ll num: ans) cout << num << ' ';
  cout << newl;
  return 0;
}