#include <bits/stdc++.h>
using namespace std;
#define ll long long
//clt + alt + b = run code

int main()
{
   int n, m;
   cin >> n >> m;
   ll a = 0, b = 0;
   for(int i = 0; i < n; i++)
   {
       string s;
       cin >> s;
       int cnt = 0;
       for(int j = 0; j < m; j++)
       {
           if(s[j] == '1') cnt++;
       }
       if(cnt % 2) a++;
       else b++;
   }

   cout << a * b << endl;



}

#include <bits/stdc++.h>
using namespace std;

vector<bool> city(2000,false);
void search(int x,vector<vector<int>> &z){
if(city.at(x) == true){
  return;
}
city.at(x) = true;
for(int i : z.at(x)) search(i,z);
}

int main(){
int n,m,a,b,ans=0; cin >> n >> m;
vector<vector<int>> road(n);
for(int i=0;i<n;i++) road.at(i).push_back(i);
for(int i=0;i<m;i++){
   cin >> a >> b;
   road.at(a-1).push_back(b-1);
}
for(int i=0;i<n;i++){
   search(i,road);
   for(int j=0;j<n;j++){
      if(city.at(j)){
        ans++;
        city.at(j) = false;
      }
   }
}
cout << ans << endl;
}