#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii              pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define __              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) 		for(int i=a;i<b;i++)
#define repb(i,a,b) 	for(int i=a;i>=b;i--)
#define endl			"\n"
#define m(a)		    memset(a,0,sizeof(a))
#define all(x)                          begin(x), end(x)

void fastscan(int &x){
bool neg = false;register int c;
x = 0;c = getchar();
if(c=='-'){neg = true;c = getchar();}
for(; (c>47 && c<58); c=getchar()){x = x *10 + c - 48;}
if(neg){x *= -1;}}

void file(){
	#ifndef ONLINE_JUDGE
	freopen("in.txt" , "r" , stdin);
	freopen("out.txt" , "w" , stdout);
	#endif
}

int bs(int a[] , int s , int e, int x){
	if(s<=e){
		int m = (s+e)/2;
		if(a[m]==x)
			return m;
		else if(a[m] > x)
			return bs(a,s,m-1,x);
		else return bs(a,m+1,e,x);
	}
	return -1;
}

#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;

#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define deb3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
#define deba(a) for(auto &x:a) cout<<x<<" ";

#define sd(x) cin >> x;
#define sd2(x,y) cin >> x >> y;
#define sd3(x,y,z) cin >> x >> y >> z;
#define sd4(w,x,y,z) cin >> w >> x >> y >> z;

bool is_pal(string s) {return equal(all(s), s.rbegin());}

int mypow(int a, int b){        //(logn) fast exponentiation
    int res = 1;            // call int x = mypow(2,5);
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return (res%mod);
}

const string t = "abacaba";

bool check(string s){
	int cnt=0;
	for(int i=0 ; i<s.length()-7+1 ; ++i){
		if(s.substr(i , 7)==t){
			++cnt;
		}
	}
	return cnt==1;
}

void solve1(){
	//657 div2 A
	int n; sd(n); string s; cin>>s;
	int l = s.length();
	int f=0;
	for(int i=0 ; i<l-7+1 ; ++i){
		bool ok=1;
		string ss = s;
		for(int j=0 ; j<7 ; ++j){
			if(ss[i+j] != t[j] and ss[i+j] != '?'){
				ok=0;
				break;
			}
			ss[i+j] = t[j];
		}
		if(ok and check(ss)==1){
			for(int i=0 ; i<l; ++i)
				if(ss[i]=='?')
					ss[i]='z';
			f=1;
			cout <<"YES"<< endl;
			cout << ss << endl;
			return;
		}
	}
	if(!f){
		cout << "NO" << endl;
		return;
	}
}	

void solve2(){
	int n,m; sd2(n,m);
	int a[n]; int b[m];
	map<int,int>m1,m2; 
	for(int i=0 ; i<n ; ++i){
		sd(a[i]);
		m1[a[i]]++;
	}
	for(int i=0 ; i<m ; ++i){
		sd(b[i]);
		m2[b[i]]++;
	}
	int f=0;
	for(auto itr : m1){
		if(m2.find(itr.ff) != m2.end()){
			f=1;
			cout <<"YES"<<endl;
			cout << 1 << " " << itr.ff << endl; return;
		}
	}
	if(!f){
		cout <<"NO"<<endl; return;
	}
}

int bs(vi a , int s , int e , int x){
	while(s<=e){
		int m = s+(e-s)/2;
		if(a[m]==x) return m;
		else if(a[m] < x) s = m+1;
		else e = m-1;
	}
	return -1;
}

int divis(int n){
	int ans=inf;
	for(int i=2 ; i*i<n+1 ; ++i){
		if(n%i==0 and n&1){
			ans = min(ans, i);
			if((n/i)&1)
			{
				ans = min(ans , (n/i));
			}
		}
	}
	return ans;
}

void solve3(){
	//not sure, submission queue..
	int n; sd(n);
	int cur=0;
	if(n==1){
		cout<<"FastestFinger"<<endl; return;
	}
	else if(n==2){
		cout<<"Ashishgup"<<endl; return;
	}
	while(n>1){
		int x = divis(n);
		int f=0;
		if(x==inf) f=1;
		if(n%x==0 and !f){
			n/=x;
		}
		else n--;
		cur^=1;
	}
	if(cur){
		cout << "FastestFinger" << endl;
	}
	else cout <<"Ashishgup" << endl;
}

int phi(int n){
	//get prime factors..=> run time O(sqrt(N))..
	int res = n;
	for(int i=2 ; i*i<n+1 ; ++i){
		if(n%i==0){
			res/=i;
			res*=(i-1);
			while(n%i==0){
				n/=i;
			}
		}
	}
	if(n>1){
		res/=n;
		res*=(n-1);
	}
	return res;
}


const int N = 1e5+5;
int arr[N];
void init(){
	//generate all phi(i) from 1 => n, in O(Nlog(logN))..
	rep(i,0,N+1){
		arr[i] = i;
	}
	for(int i=2 ; i<=N ; i++){
		if(arr[i]==i){
			arr[i] = i-1;
			for(int j=2*i ; j<=N ; j+=i){
				arr[j]/=j;
				arr[j]*=(j-1);
			}
		}
	}
}

void solve(){
	int n; sd(n);
	int cur=0;
	while(1000*cur<n){
		++cur;
	}
	cout << cur*1000 - n << endl;
}

int32_t main(){	
	__;
	file();
	solve();
	return 0;
}





Measured memory_bytes: 3604