#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T mod_v(T num) {
  if (num >= 0)
    return num % 1000000007;
  else
    return (num % 1000000007 + 1000000007) % 1000000007;
}
template <class T>
inline T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
template <class T>
T fast_pow(T n, T p) {
  if (p == 0) return 1;
  if (p % 2) {
    T g = mod_v(mod_v(n) * mod_v(fast_pow(n, p - 1)));
    return g;
  } else {
    T g = fast_pow(n, p / 2);
    g = mod_v(mod_v(g) * mod_v(g));
    return g;
  }
}
template <class T>
inline T modInverse(T n) {
  return fast_pow(n, 1000000007 - 2);
}
template <class T>
inline void debug(string S1, T S2, string S3) {
  cout << S1 << S2 << S3;
}
template <class T>
inline T in() {
  register char c = 0;
  register T num = 0;
  bool n = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-')
      n = true;
    else
      num = num * 10 + c - '0';
    c = getchar();
  }
  return n ? -num : num;
}
class data {
 public:
  int t, w;
};
int dp[108][208][208];
int n;
data ara[108];
vector<int> ans;
int re(int p, int s, int u) {
  if (p == n) {
    return s;
    return ((s >= u) ? s : 100000000);
  }
  if (dp[p][s][u] != -1) return dp[p][s][u];
  dp[p][s][u] = 1 << 30;
  if (u - ara[p].w - ara[p].t >= 0) {
    dp[p][s][u] =
        min(dp[p][s][u], re(p + 1, s - ara[p].t, u - ara[p].t - ara[p].w));
  }
  ans.push_back(p + 1);
  dp[p][s][u] = min(dp[p][s][u], re(p + 1, s, u));
  ans.pop_back();
  return dp[p][s][u];
}
int main() {
  n = in<int>();
  int t = 0, w = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &ara[i].t, &ara[i].w);
    t += ara[i].t;
  }
  memset(dp, -1, sizeof(dp));
  ;
  printf("%d\n", re(0, t, t));
  return 0;
}
