#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3000 * 1005;
const long long INF = 1E12;
const long long MOD = 1000000009;
const double PI = 2 * acos(0.0);
long long n, t, ans = 0;
long long item[105][2005], sz[105], dp[105][2005];
pair<long long, long long> N[1005];
int main(void) {
  cin >> n >> t;
  for (long long i0 = 0; i0 < n; i0++) {
    cin >> N[i0].first >> N[i0].second;
  }
  sort(N, N + n, greater<pair<long long, long long> >());
  for (long long i0 = 0; i0 < n; i0++) {
    item[N[i0].first][sz[N[i0].first]] = N[i0].second;
    sz[N[i0].first]++;
  }
  for (long long i0 = 0; i0 < n; i0++) {
    dp[1][i0] = item[1][i0];
  }
  for (long long w = 2; w <= t; w++) {
    long long i = 0, j = 0;
    for (long long i0 = 0; i0 < n; i0++) {
      dp[w][i0] = item[w][i];
      if (dp[w][i0] < dp[w - 1][2 * j] + dp[w - 1][(2 * j) + 1]) {
        dp[w][i0] = dp[w - 1][2 * j] + dp[w - 1][(2 * j) + 1];
        j++;
      } else
        i++;
    }
  }
  cout << dp[t][0] << endl;
  return 0;
}
