#include <bits/stdc++.h>
using namespace std;
void run();
int main() {
  ios::sync_with_stdio(0);
  run();
}
map<int, int> got;
void run() {
  int n, most = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int g, sz;
    cin >> sz >> g;
    most = max(most, sz);
    got[sz] = g;
  }
  while (got.size() > 1 or got.begin()->second > 1) {
    int x = got.begin()->first;
    int y = got.begin()->second;
    if (y == 1) {
      map<int, int>::iterator it = got.begin();
      ++it;
      if (not it->second) ++it->second;
    } else {
      int will = (y + 3) / 4;
      got[x + 1] += will - min(will, got[x + 1]);
    }
    got.erase(got.begin());
  }
  cout << max(most + 1, got.begin()->first) << endl;
}
