#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long inf = 0x3f3f3f3f;
const long long INFF = 1e18 + 5;
const long long INF = 1e9;
const long long MX = 2e6 + 5;
const long long MXL = 105;
const long long mod = 1e9 + 7;
const double ERROR = 1e-7;
long long n, T, t, q;
vector<long long> dp[105];
void solve() {
  cin >> n >> T;
  for (long long i = 1; i <= n; i++) {
    cin >> t >> q;
    dp[t].push_back(q);
  }
  for (long long i = 1; i <= T; i++) {
    sort(dp[i].begin(), dp[i].end(), greater<long long>());
    for (long long j = 0; j < dp[i].size(); j += 2) {
      if (j + 1 < dp[i].size())
        dp[i + 1].push_back(dp[i][j] + dp[i][j + 1]);
      else
        dp[i + 1].push_back(dp[i][j]);
    }
  }
  cout << dp[T][0] << "\n";
}
int32_t main() { solve(); }
