#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int f[4001];

void cheat();

int main(){
	fill(f, f + 4001, -1);
	cheat();
	int n;
	while( cin >> n ){
		if( f[n] != -1 ){
			cout << f[n] << endl;
			continue;
		}
		
		vector<int> v;
		for(int i = 0; i <= 1000; i++){
			if( n < i ) break;
			for(int j = 0; j <= 1000; j++){
				if( n < i + j ) break;
				if( n <= i + j + 2000 ) v.push_back(i + j);
			}
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for(int i = 0; i < v.size(); i++){
			int k = n - v[i];
			int res = upper_bound(v.begin(), v.end(), k) - lower_bound(v.begin(), v.end(), k);
			ans += res;
		}
		f[n] = f[4000 - n] = ans;
		cout << f[n] << endl;
	}
}

void cheat(){
f[2000] = 668669001;
f[2010] = 668569396;
f[2020] = 668272591;
f[2030] = 667781586;
f[2040] = 667099381;
f[2050] = 666228976;
f[2060] = 665173371;
f[2070] = 663935566;
f[2080] = 662518561;
f[2090] = 660925356;
f[2100] = 659158951;
f[2110] = 657222346;
f[2120] = 655118541;
f[2130] = 652850536;
f[2140] = 650421331;
f[2150] = 647833926;
f[2160] = 645091321;
f[2170] = 642196516;
f[2180] = 639152511;
f[2190] = 635962306;
f[2200] = 632628901;
f[2210] = 629155296;
f[2220] = 625544491;
f[2230] = 621799486;
f[2240] = 617923281;
f[2250] = 613918876;
f[2260] = 609789271;
f[2270] = 605537466;
f[2280] = 601166461;
f[2290] = 596679256;
f[2300] = 592078851;
f[2310] = 587368246;
f[2320] = 582550441;
f[2330] = 577628436;
f[2340] = 572605231;
f[2350] = 567483826;
f[2360] = 562267221;
f[2370] = 556958416;
f[2380] = 551560411;
f[2390] = 546076206;
f[2400] = 540508801;
f[2410] = 534861196;
f[2420] = 529136391;
f[2430] = 523337386;
f[2440] = 517467181;
f[2450] = 511528776;
f[2460] = 505525171;
f[2470] = 499459366;
f[2480] = 493334361;
f[2490] = 487153156;
f[2500] = 480918751;
f[2510] = 474634146;
f[2520] = 468302341;
f[2530] = 461926336;
f[2540] = 455509131;
f[2550] = 449053726;
f[2560] = 442563121;
f[2570] = 436040316;
f[2580] = 429488311;
f[2590] = 422910106;
f[2600] = 416308701;
f[2610] = 409687096;
f[2620] = 403048291;
f[2630] = 396395286;
f[2640] = 389731081;
f[2650] = 383058676;
f[2660] = 376381071;
f[2670] = 369701266;
f[2680] = 363022261;
f[2690] = 356347056;
f[2700] = 349678651;
f[2710] = 343020046;
f[2720] = 336374241;
f[2730] = 329744236;
f[2740] = 323133031;
f[2750] = 316543626;
f[2760] = 309979021;
f[2770] = 303442216;
f[2780] = 296936211;
f[2790] = 290464006;
f[2800] = 284028601;
f[2810] = 277632996;
f[2820] = 271280191;
f[2830] = 264973186;
f[2840] = 258714981;
f[2850] = 252508576;
f[2860] = 246356971;
f[2870] = 240263166;
f[2880] = 234230161;
f[2890] = 228260956;
f[2900] = 222358551;
f[2910] = 216525946;
f[2920] = 210766141;
f[2930] = 205082136;
f[2940] = 199476931;
f[2950] = 193953526;
f[2960] = 188514921;
f[2970] = 183164116;
f[2980] = 177904111;
f[2990] = 172737906;
f[3000] = 167668501;
f[3010] = 162698416;
f[3020] = 157827531;
f[3030] = 153054846;
f[3040] = 148379361;
f[3050] = 143800076;
f[3060] = 139315991;
f[3070] = 134926106;
f[3080] = 130629421;
f[3090] = 126424936;
f[3100] = 122311651;
f[3110] = 118288566;
f[3120] = 114354681;
f[3130] = 110508996;
f[3140] = 106750511;
f[3150] = 103078226;
f[3160] = 99491141;
f[3170] = 95988256;
f[3180] = 92568571;
f[3190] = 89231086;
f[3200] = 85974801;
f[3210] = 82798716;
f[3220] = 79701831;
f[3230] = 76683146;
f[3240] = 73741661;
f[3250] = 70876376;
f[3260] = 68086291;
f[3270] = 65370406;
f[3280] = 62727721;
f[3290] = 60157236;
f[3300] = 57657951;
f[3310] = 55228866;
f[3320] = 52868981;
f[3330] = 50577296;
f[3340] = 48352811;
f[3350] = 46194526;
f[3360] = 44101441;
f[3370] = 42072556;
f[3380] = 40106871;
f[3390] = 38203386;
f[3400] = 36361101;
f[3410] = 34579016;
f[3420] = 32856131;
f[3430] = 31191446;
f[3440] = 29583961;
f[3450] = 28032676;
f[3460] = 26536591;
f[3470] = 25094706;
f[3480] = 23706021;
f[3490] = 22369536;
f[3500] = 21084251;
f[3510] = 19849166;
f[3520] = 18663281;
f[3530] = 17525596;
f[3540] = 16435111;
f[3550] = 15390826;
f[3560] = 14391741;
f[3570] = 13436856;
f[3580] = 12525171;
f[3590] = 11655686;
f[3600] = 10827401;
f[3610] = 10039316;
f[3620] = 9290431;
f[3630] = 8579746;
f[3640] = 7906261;
f[3650] = 7268976;
f[3660] = 6666891;
f[3670] = 6099006;
f[3680] = 5564321;
f[3690] = 5061836;
f[3700] = 4590551;
f[3710] = 4149466;
f[3720] = 3737581;
f[3730] = 3353896;
f[3740] = 2997411;
f[3750] = 2667126;
f[3760] = 2362041;
f[3770] = 2081156;
f[3780] = 1823471;
f[3790] = 1587986;
f[3800] = 1373701;
f[3810] = 1179616;
f[3820] = 1004731;
f[3830] = 848046;
f[3840] = 708561;
f[3850] = 585276;
f[3860] = 477191;
f[3870] = 383306;
f[3880] = 302621;
f[3890] = 234136;
f[3900] = 176851;
f[3910] = 129766;
f[3920] = 91881;
f[3930] = 62196;
f[3940] = 39711;
f[3950] = 23426;
f[3960] = 12341;
f[3970] = 5456;
f[3980] = 1771;
f[3990] = 286;
f[4000] = 1;
}