#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define mmod 998244353
#define inf 1000000000000000000
#define PI 3.141592653589793238
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,n) x.clear();x.resize(n,0)
#define precise(x) fixed<<setprecision(x)
#define popcount(x) __builtin_popcountll(x)
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update> ordered_multiset;

/**
 *  author: nayakashutosh9
 *	created: [2021-04-18 17:27]
 *	"Compete against yourself"
**/

const int N = 3e5 + 5;

void solve() {
	int a, b; cin >> a >> b;
	vi pos, neg;
	int n = max(a, b);
	for (int i = 1; i <= n; i++) pos.pb(i);
	for (int i = 1; i <= n; i++) neg.pb(-i);
	if (a >= b) {
		int dif = a - b;
		while (dif > 0) {
			neg[sz(neg) - 2] += neg[sz(neg) - 1];
			neg.pop_back();
			dif--;
		}
	}
	else {
		int dif = b - a;
		while (dif > 0) {
			pos[sz(pos) - 2] += pos[sz(pos) - 1];
			pos.pop_back();
			dif--;
		}
	}
	for (int i : pos) cout << i << " ";
	for (int i : neg) cout << i << " ";
	cout << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	//cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		//cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
	}

	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int read()
{
    int num=0;bool flag=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar())
      if(c=='-')flag=0;
    for(;c>='0'&&c<='9';c=getchar())
      num=(num<<1)+(num<<3)+c-'0';
    return flag?num:-num;
}
int n,m;
int jo[5];
char c[30];
long long ans;
int main(){
	n=read();
	m=read();
	int cnt=0;
	for(int i=1;i<=n;i++){
		scanf("%s",c+1);
		cnt=0;
		for(int j=1;j<=m;j++) if(c[j]=='1') cnt++;
		if(cnt%2==1){
			ans+=jo[2];
			jo[1]++;
		}
		else {
			ans+=jo[1];
			jo[2]++;
		}
	}
	cout<<ans;
	return 0;
}