#include<iostream>
#include<vector>
using namespace std;
const int BUF = 100005;
const int BIT = 25;

int N, M;
int val[BUF];

void read() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        val[i] = 0;
        for (int j = 0; j < M; ++j) {
            val[i] <<= 1;
            val[i] += s[j] - '0';
        }
    }
}



void work() {
    int cnt[BIT] = {};
    for (int i = 0; i < N; ++i) {
        ++cnt[__builtin_popcount(val[i])];
    }

    long long ans = 0;
    for (int i = 0; i < BIT; ++i) {
        for (int j = i + 1; j < BIT; ++j) {
            if (abs(i - j) % 2 == 1) {
                ans += 1LL * cnt[i] * cnt[j];

            }
        } 
    }
    cout <<  ans << endl;
}


int main() {
    read();
    work();
    return 0;
}

#include<bits/stdc++.h>
#define FOR(i,s,t) for(int i=s;i<=t;++i)
#define REP(i,t,s) for(int i=t;i>=s;--i)
#define RESET(a) memset(a,0,sizeof a)
using namespace std;
typedef long long ll;
const ll M=3e10;
char s[200005];
int n,vi[3];
int main() {
	scanf("%d%s",&n,s);
	FOR(i,0,n-1) {
		s[i]-='0';
		if((s[i]==0)^(i%3==0)) vi[0]=1;
		if((s[i]==0)^(i%3==1)) vi[1]=1;
		if((s[i]==0)^(i%3==2)) vi[2]=1;
	}
	ll ans=0;
	if(!vi[2]) {
		ans+=(M-n)/3+1;
	}
	if(!vi[1]) {
		ans+=(M-n-1)/3+1;
	}
	if(!vi[0]) {
		ans+=(M-n-2)/3+1;
	}
	cout<<ans;
}