#include <bits/stdc++.h>
static const int INF = std::numeric_limits<int>::max();
int dp[101][201];
int main() {
  int n;
  std::cin >> n;
  std::vector<int> t(n), w(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> t[i] >> w[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 200; ++j) {
      if (dp[i][j] == -1) continue;
      if (dp[i + 1][j] == -1) {
        dp[i + 1][j] = dp[i][j] + w[i];
      } else {
        dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j] + w[i]);
      }
      if (dp[i + 1][j + t[i]] == -1) {
        dp[i + 1][j + t[i]] = dp[i][j];
      } else {
        dp[i + 1][j + t[i]] = std::min(dp[i + 1][j + t[i]], dp[i][j]);
      }
    }
  }
  int res = INF;
  for (int i = 0; i <= 200; ++i) {
    if (dp[n][i] == -1 || dp[n][i] > i) continue;
    res = i;
    break;
  }
  std::cout << res << std::endl;
}
