#include <iostream>
using namespace std;

int main() {
  int n, nn, l;
  int ans;
  while (cin >> n) {
    if (n<=1000 || n>=3000) {
      nn = (n<=1000) ? n : 4000-n;
      ans = (nn+3)*(nn+2)*(nn+1)/6;
    } else {
      ans = 0;
      nn = (n>2000) ? 4000-n : n;
      l = nn-1000;
      ans = 167167*(3*nn-1997);
      ans += l*(l+1)*(999-l)>>1;
    }
    cout << ans << endl;
  }
  return 0;
}