#include <bits/stdc++.h>
using namespace std;
long long modpow(long long base, long long exponent, long long modulus) {
  long long result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
int N;
int ln[104];
int tk[105];
bool dp[105][207][205];
inline void ReadInput(void) {
  cin >> N;
  for (int i = (0); i < (N); i++) {
    cin >> tk[i];
    cin >> ln[i];
  }
}
inline void solve(void) {
  for (int i = (0); i < (N + 1); i++)
    for (int j = (0); j < (202); j++)
      for (int k = (0); k < (202); k++) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 2 * N; j++) {
      for (int k = 0; k <= 2 * N; k++) {
        if (i == 1) {
          dp[i][tk[i - 1]][0] = 1;
          dp[i][0][ln[i - 1]] = 1;
        } else {
          int t1 = 0, t2 = 0;
          if (j >= tk[i - 1]) {
            t1 = dp[i - 1][j - tk[i - 1]][k];
          }
          if (k >= ln[i - 1]) {
            t2 = dp[i - 1][j][k - ln[i - 1]];
          }
          dp[i][j][k] |= t1;
          dp[i][j][k] |= t2;
        }
      }
    }
  }
  int ans = 1000000;
  for (int j = (0); j < (2 * N + 1); j++) {
    for (int k = (0); k < (2 * N + 1); k++) {
      if (dp[N][j][k] && j >= k) {
        ans = ((ans) < (j) ? ans : j);
      }
    }
  }
  cout << ans << endl;
}
inline void Refresh(void) {}
int main(int argc, const char* argv[]) {
  ReadInput();
  solve();
  return 0;
}
