n = gets.to_i
c = Array.new(n+1, 0)
w = Array.new(n+1, 0)
(1..n).each do |i|
  c[i], w[i] = gets.split.map(&:to_i)
end
dp = Array.new(n+1){ Array.new(n+1, 0) }
ret = Array.new(n+1, 0)
(1..n).each do |i| 
  dp[i][i] = c[i]
  ret[i] = ret[i-1] + 1
  x = w[i]
  y = w[i-1]
  (i-1).downto(1) do |j|
    dp[j][i] = [[dp[j+1][i], a[j] - x].min, [dp[j][i-1], a[i] - y].min].max
    x += w[j]
    y += w[j-1]
    break if dp[j][i] < 0
    ret[i] = ret[j-1] + 1
  end
end
puts ret[n]