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

void sort2vectors(vector<__int64_t> &av, vector<__int64_t> &bv){
   int n = av.size();
   vector<__int64_t> p(n), av2(n), bv2(n);
   iota(p.begin(), p.end(), 0);
   sort(p.begin(), p.end(), [&](__int64_t a, __int64_t b) { return av[a] < av[b]; });
   for (int i = 0; i < n; i++) {
       av2[i] = av[p[i]];
       bv2[i] = bv[p[i]];
   }
   av = av2;
   bv = bv2;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<__int64_t> Avec(N), Bvec(N);
    for(int i=0; i<N; i++)
    {
        cin >> Avec.at(i) >> Bvec.at(i);
    }
    sort2vectors(Avec, Bvec);


    __int64_t Money = K;
    
    for(int i=0; i<N; i++)
    {
        if(Money >= Avec.at(i))
        {
            Money += Bvec.at(i);
        }
    }
    cout << Money;
}
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> S(N);
	REP(i, N) cin >> S[i];
	
	ll odd = 0, even = 0;
	FOR(i, 1, N) {
		int cnt = 0;
		REP(j, M) if (S[0][j] != S[i][j]) ++cnt;
		if (cnt & 1) ++odd;
		else ++even;
	}
	
	ll ans = odd;
	ans += odd * even;
	cout << ans << endl;
}