#include <bits/stdc++.h>
using namespace std;
inline bool xdy(double x, double y) { return x > y + 1e-9; }
inline bool xddy(double x, double y) { return x > y - 1e-9; }
inline bool xcy(double x, double y) { return x < y - 1e-9; }
inline bool xcdy(double x, double y) { return x < y + 1e-9; }
int n;
int t[104];
int w[104];
int dp[2 * 104];
int main() {
  ios_base::sync_with_stdio(0);
  while (~scanf("%d", &n)) {
    int all = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &t[i], &w[i]);
      all += w[i];
    }
    for (int i = 0; i <= 200; i++) dp[i] = -(1 << 29);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 200; j >= t[i]; j--) {
        dp[j] = max(dp[j], dp[j - t[i]] + w[i]);
      }
    }
    int i;
    for (i = 0; i <= 200; i++) {
      if (i >= all - dp[i]) break;
    }
    printf("%d\n", i);
  }
}
