#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
const int N = 1010;
const int M = 3200;
const int mod = 998244353;


int a[2];
void solve() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        int cnt = 0;
        for (int j = 0; j < s.length(); ++j) {
            cnt += s[j] - '0';
        }
        a[cnt & 1]++;
    }
    printf("%lld\n", a[0] * 1ll * a[1]);
}



int main() {
#ifdef HAMLET
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
    return 0;
}

#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <list>
#include <cassert>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define ll long long
#define repi(i,a,b) for(ll i=a;i<b;++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
using vvv = vector<vector<vector<ll>>>;
using vv = vector<vector<ll>>;
using vec = vector<ll>;
using P = pair<ll, ll>;

int main(void) {
    ll n, m; cin >> n >> m;
    ll cnt = 0;
    string start; cin >> start;
    vector<bool> ml(n - 1);
    rep(i, n - 1){
        string s; cin >> s;
        ll match = 0;
        rep(j, m){
            if(s[j] == start[j]) match++;
        }
        if(m % 2 && match % 2 == 0){
            ml[i] = 1;
            cnt++;
        } 
        if(m % 2 == 0 && match % 2){ 
            ml[i] = 1;
            cnt++;
        }
        //cout << ml[i] << endl;
    }
    ll ans = cnt;
    ll unMatch = n - cnt - 1;
    rep(i, n - 1){
        if(ml[i] == 1){
            ans += unMatch;
            cnt--;
        }
        else{
            ans += cnt;
            unMatch--;
        }
    }
    cout << ans << endl;
}