#include <bits/stdc++.h>
using namespace std;
int dp[300];
int main() {
  int n;
  cin >> n;
  for (int i = (0); i < int(300); i += 1) dp[i] = -1;
  dp[0] = 0;
  while (n--) {
    int a, b;
    cin >> a >> b;
    for (int i = (299); i > int(0 - 1); i -= 1) {
      int bst = ((1 << 29) - 1);
      if (i >= a && dp[i - a] != -1) bst = dp[i - a];
      if (dp[i] != -1) bst = min(bst, dp[i] + b);
      if (bst == ((1 << 29) - 1)) bst = -1;
      dp[i] = bst;
    }
  }
  for (int i = (0); i < int(250); i += 1)
    if (dp[i] != -1 && i >= dp[i]) {
      cout << i;
      exit(0);
    }
  return 0;
}
