memo1 = (0..4000).map{|i| i<=1000 ? 1 : 0}
cum1 = Array.new(4001, 1)
(1..4000).each{|i| cum1[i] = cum1[i-1] + memo1[i]}
memo2 = (0..4000).map{|i| (i<=1000) ? (cum1[i]) : (cum1[i] - cum1[i-1001])}
cum2 = Array.new(4001, 1)
(1..4000).each{|i| cum2[i] = cum2[i-1] + memo2[i]}
memo3 = (0..4000).map{|i| (i<=1000) ? (cum2[i]) : (cum2[i] - cum2[i-1001])}
cum3 = Array.new(4001, 1)
(1..4000).each{|i| cum3[i] = cum3[i-1] + memo3[i]}
memo4 = (0..4000).map{|i| (i<=1000) ? (cum3[i]) : (cum3[i] - cum3[i-1001])}

while (ln = gets)
  n = ln.to_i
  p memo4[n]
end
