// https://szkopul.edu.pl/problemset/problem/xApOd_fcsVrm_DV7HljFbLWq/site/?key=statement
#include <iostream>
#include <map>
constexpr int sizik = 1000 * 1001;
int pref[sizik];
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n;
std::cin >> n;
std::map<int, int> m;
for (int i = 1; i <= n; i++) {
int a, b;
std::cin >> a >> b;
pref[i] = pref[i - 1] + b - a;
m[pref[i]]++;
}
int maxi = 0;
for (const auto& p : m) {
maxi = std::max(maxi, p.second);
}
std::cout << n - maxi << '\n';
return 0;
}