#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vii = vector<vector<int>>;
using vll = vector<vector<ll>>;
using vcc = vector<vector<char>>;
using vs = vector<string>;
using Pi = pair<int , int>;
using Pl = pair<ll, ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(n) for (ll i = 0; i < n; i++)
#define repint(i, n) for (int i = 0; i < n; i++)
#define rep2(i, s, n) for (int i = (s); i < n; i++)
#define REP2(s, n) for (int i = (s); i < n; i++)
#define rep3(i ,j, n, m) rep(i, n)rep(j, m)
#define REP3(n, m) rep(i, n)rep(j, m)
#define sort(A) sort(A.begin(),A.end());
#define reverse(A) reverse(A.begin(),A.end());
#define k(s) cout << fixed << setprecision(s);
const long double pi=3.14159265358979323846;
const long long MOD=1000000007;

int main() {
    int n, m;
    cin >> n >> m;

    int t[2] = {0, 0};
    while(n--) {
        string s;
        cin >> s;
        int cc = 0;
        for(char&c : s) {
            cc ^= (c - '0');
        }
        t[cc]++;
    }

    cout << 1LL * t[0] * t[1];
}
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define reps(i,s,n) for(int i=s;i<n;++i)
using ll = long long;
using namespace std;

int main() 
{
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n) 
    {
        ll a, b; cin >> a >> b;
        ll s1 = b * (b + 1) / 2;
        ll s2 = a * (a + 1) / 2;
        ans += s1 - s2 + a;
    }

    cout << ans << endl;
    return 0;
}