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

int main(){
 
 ll n,m;
 cin>>n>>m;
 vector<string> a(n);
 
 for(int i=0;i<n;i++){
     cin>>a[i];
 }
//  vector<ll> b(n);
 ll e=0,o=0;
 for(int i=0;i<n;i++){
     int c=0;
     for(int j=0;j<a[i].length();j++){
         c+=a[i][j]-'0';
     }
    //  b[i]=c;
     if(c%2){
         o++;
     }else{
         e++;
     }
 }
 
//  sort(b.begin(),b.end());
 
 ll ans=n*(n-1)/2;
 
//  ll d=1;
//  for(int i=1;i<n;i++){
//      if(b[i]!=b[i-1]){
//          ans-=d*(d-1)/2;
//          d=1;
//      }else{
//          d++;
//      }
//  }
 
//  ans-=d*(d-1)/2;

 ans-=e*(e-1)/2;
 ans-=o*(o-1)/2;

 
 cout<<ans;
 
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
template <class T1, class T2>
bool chmax(T1 &a, const T2 b) { if (a < b) { a = b; return true; } return false; }
template <class T1, class T2>
bool chmin(T1 &a, const T2 b) { if (a > b) { a = b; return true; } return false; }
template <class T>
istream &operator>>(istream &is, vector<T> &v) { for (T &i : v) is >> i; return is; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &i : v) os << i << ' '; return os; }
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) { cout << head << ' '; co(forward<Tail>(tail)...); }
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) { cerr << head << ' '; ce(forward<Tail>(tail)...); }
void sonic() { ios::sync_with_stdio(false); cin.tie(nullptr); }
void setp(const int n) { cout << fixed << setprecision(n); }
constexpr int64_t LINF = 1000000000000000001;
constexpr int64_t MOD = 1000000007;
constexpr int64_t MOD_N = 998244353;
constexpr long double EPS = 1e-11;
const double PI = acos(-1);

template <typename T>
struct BIT {
    int64_t N;
    vector<T> data;

    BIT(int64_t n) {
        init(n);
    }

    const T &operator[](const int64_t i) const {
        return at(i);
    }

    T at(int64_t k) { return sum(k) - sum(k - 1); }

    void init(int64_t n) {
        N = 1;
        while (N <= n) N <<= 1;
        data.assign(N, 0);
    }

    void build(vector<T> v) {
        init(N);
        for (int i = 0; i < v.size(); ++i) {
            add(i, v[i]);
        }
    }

    void add(int64_t k, T x) {
        ++k;
        while (k <= N) {
            data[k] += x;
            k += k & -k;
        }
    }

    void update(int64_t k, T x) {
        add(k, x - at(k));
    }

    T sum(int64_t k) {
        T res = 0;
        while (k) {
            res += data[k];
            k -= k & -k;
        }
        return res;
    }

    T sum(int64_t a, int64_t b) { return sum(b) - sum(a); }

    T lower_bound(T k) {
        int64_t l = 0, r = N;
        while (r - l > 1) {
            int64_t m = (l + r) / 2;
            if (sum(m) >= k) r = m;
            else l = m;
        }
        return r;
    }
};

int main(void) {
    ll h, w;
    cin >> h >> w;
    ll m;
    cin >> m;
    VecP ps(m);
    rep(i, m) cin >> ps[i].first >> ps[i].second;
    sort(all(ps));

    Vec my(h + 1, w + 1);
    rep(i, m) chmin(my[ps[i].first], ps[i].second);
    repn(i, h) {
        if (my[i - 1] == 1) my[i] = 1;
    }

    BIT<ll> bit(w + 10);
    set<ll> st;

    REPN(i, my[1], w) {
        bit.add(i, 1);
        st.insert(i);
    }

    ll ans = 0;
    ll pos = 0;
    repn(i, h) {
        while (pos < m && ps[pos].first == i) {
            if (st.find(ps[pos].second) == st.end()) {
                bit.add(ps[pos].second, 1);
                st.insert(ps[pos].second);
            }
            ++pos;
        }
        ans += bit.sum(my[i], w + 1);
        // ce(i, ans);
    }
    co(h * w - ans);

    return 0;
}