while s=gets
  i=s.chomp.to_i
  count=0
  if i>2000 then
    i=4000-i
  end

  1001.times{ |a|
    if a>i then
      break
    end
    1001.times{ |b|
      if a+b>i || i-a-b>2000 then
        break
      end
      if i-a-b>1000 then
        count+=(2001-(i-a-b))
      else
        count+=(i-a-b+1)
      end

    }
  }
  p count
end

