#include <bits/stdc++.h>
using pair_type = std::pair<int, int>;
int n, t;
void print(std::vector<pair_type> const& v) {
  for (auto i : v) std::cerr << "{" << i.first << ", " << i.second << "}  ";
  std::cerr << '\n';
}
int main() {
  std::cin >> n >> t;
  auto cmp = [](pair_type const& a, pair_type const& b) {
    return a.first > b.first || (a.first == b.first && a.second < b.second);
  };
  std::priority_queue<pair_type, std::vector<pair_type>, decltype(cmp)> pq(cmp);
  int ans = 0;
  for (int i = 0, cost, value; i < n; i++) {
    std::cin >> cost >> value;
    pq.push({cost, value});
    if (cost <= t) ans = std::max(ans, value);
  }
  while (pq.size() > 1) {
    auto t1 = pq.top();
    pq.pop();
    auto t2 = pq.top();
    if (t1.first == t2.first) {
      pq.pop();
      auto tmp = std::make_pair(++t1.first, t1.second + t2.second);
      pq.push(tmp);
      if (tmp.first <= t) ans = std::max(ans, tmp.second);
    } else
      pq.push({++t1.first, t1.second});
  }
  std::cout << ans << '\n';
}
