#include <bits/stdc++.h>
using namespace std;
const int MXT = 205;
const int INF = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> thc(n), wid(n);
  for (int i = 0; i < n; i++) {
    cin >> thc[i] >> wid[i];
  }
  vector<vector<int>> dp(n + 1, vector<int>(MXT, INF));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < MXT; j++) {
      if (dp[i][j] != INF) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + wid[i]);
        dp[i + 1][j + thc[i]] = min(dp[i + 1][j + thc[i]], dp[i][j]);
      }
    }
  }
  int ans = INF;
  for (int j = 0; j < MXT; j++) {
    if (dp[n][j] != INF && j >= dp[n][j]) {
      ans = j;
      break;
    }
  }
  cout << ans;
}
