#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int dp[4010] = {1};
    for (int i = 0; i < 4; i++)
      for (int j = n; j >= 0; j--)
        for (int k = 1; k <= 1000; k++)
          if (j + k <= n) dp[j + k] += dp[j];
    cout << dp[n] << endl;
  }
  return 0;
}
