#include <bits/stdc++.h>
const bool DEBUG = false;
using namespace std;
template <class T>
using priority_queue_asc = priority_queue<T, vector<T>, greater<T> >;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  vector<pair<int, int> > n(N);
  for (int i = 0; i < (N); i++) {
    cin >> n[i].first >> n[i].second;
  }
  sort((n).begin(), (n).end());
  vector<vector<int> > DP;
  DP.resize(T + 1);
  auto it = n.begin();
  vector<int> possible;
  for (int t = 1; t <= T; t++) {
    vector<int> next;
    auto it2 = possible.rbegin();
    while (it2 != possible.rend()) {
      if (it2 + 1 != possible.rend()) {
        next.push_back(*it2 + *(it2 + 1));
        it2 += 2;
      } else {
        next.push_back(*it2);
        it2++;
      }
    }
    while (it->first == t) next.push_back(it->second), it++;
    sort((next).begin(), (next).end());
    possible = next;
  }
  cout << possible.back() << "\n";
  return 0;
}
