n = gets.to_i
a = Array.new(n+1, 0)
b = Array.new(n+1, 0)
(1..n).each do |i|
  a[i], b[i] = gets.split.map(&:to_i)
end
dp = Array.new(n+1){ Array.new(n+1, 0) }
ret = Array.new(n+1){ |i| i }
(1..n).each do |i| 
  dp[i][i] = a[i]
  x = b[i]
  y = b[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 += b[j]
    y += b[j-1]
    break if dp[j][i] < 0
    ret[i] = ret[j-1] + 1
  end
end
puts ret[n]