#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define ln "\n"
#define forn(i,e) for( i=0; i<e; i++)
#define forsn(i,s,e) for( i=s; i<e; i++)
#define rforn(i,e) for( i=e; i>=0; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<char>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln


#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
bool chk(int a, int b, int n, int m) {
        return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
        ll a = 1;
        while (m > 0){
                if (m&1) a = (a * n%md) % md;
                m /= 2;
                n = (n*n) % md;
        }
        return a % md;
}

void disp(vi v){
        for(auto u:v)
                cout<<u<<" ";
        cout<<"\n";
}

int getSqr(int x){
        if(x < 0)
                return -1;
        int l = sqrt(x);
        for (int i = -2; i <= 2; ++i)
                if (l + i >= 0 && (l + i) * (l + i) == x)
                        return l;
        return -1;
}

#define DEBUG
#ifdef DEBUG

#endif
const int NPRR = 1e7;
vi lp;
vector<int> pr;
void prfac(int n = NPRR){
        assert(n <= NPRR);
        lp.assign(n+1, 0);
        int i;
        for (i = 2;i <= n;++i) {
                if (lp[i] == 0) {
                        lp[i] = i;
                        pr.push_back(i);
                }
                for (int u: pr) {
                        if(i * u > n || u > lp[i]) break;
                        lp[i * u] = u;
                }
        }
}

void go2() {

        ll n, x;
        in2(n, x);
        ll i, j, k;
        ll a[n];
        forn(i, n) cin >> a[i];
        sort(a, a+n);
        bool ok[n];
        memset(ok, true, sizeof(ok));
        ll ans = 0;
        while(true) {
                auto d = lower_bound(a, a+n, x);
                if(d == a+n) {
                        break;
                }
                //if(!ok[d-a]) d++;

                //cout << a[d-a] << " " << x << " ; ";


                if(ok[d-a] && a[d - a] == x) {
                        ok[d-a] = false;
                        ans++;
                        x *= 2;
                        continue;
                }

                if(0 <= d-a-1 < n && a[d-a-1] >= a[d-a] / 2 && ok[d - a - 1]) {
                        ok[d-a-1] = false;
                        x = 2 * a[d - a-1];
                        ans++;
                        continue;
                }
                ans++;
                x *= 2;
        }
        forn(i, n) if(ok[i]) ans++;
        cout << ans << ln;

}
/*
char a[501][501];
void go1() {
        int n, m, k, i, j, l;
        in3(n, m, k);
        forn(i, n) {
                string s;
                cin >> s;
                forn(j, m) {
                        a[i][j] = s[j];
                }
        }
        map<pii, int> mm;
        priority_queue<pair<int, pii> > q;
        forn(i, n) {
                forn(j, m) {
                        if(a[i][j] == '.') {
                                forn(l ,4) {
                                        int xx = dr[l];
                                        int yy = dc[l];
                                        if(chk(xx+i, yy+j, n, m)) {
                                                mm[{i, j}] += (a[xx+i][yy+j] == '.');
                                        }
                                }
                                q.push({-mm[{i, j}], {i, j}});
                        }
                }
        }

        while(!q.empty()) {
                if(k <= 0) {
                        break;
                }
                pii p = q.top().S;
                q.pop();
                if(a[p.F][p.S] != '.') continue;
                if(a[p.F][p.S] == 'X') continue;
                a[p.F][p.S] = 'X';
                k--;

                forn(l ,4) {
                        int xx = dr[l];
                        int yy = dc[l];
                        if(chk(xx+p.F, yy+p.S, n, m)) {
                                if(a[xx+p.F][yy+p.S] == '.') {
                                        mm[{xx+p.F, yy+p.S}]--;
                                        q.push({-mm[{xx+p.F, yy+p.S}], {xx+p.F, yy+p.S}});
                                }
                        }
                }
        }
        forn(i, n) {
                forn(j, m) cout << a[i][j];
                cout << ln;
        }

}*/
/*
vector<pii> ad[100005];
void go1() {

        ll n, m;
        in2(n, m);
        ll i, j, k;
        set<pii> ss;
        forn(i, m) {
                ll r, s, w;
                in3(r, s, w);
                if(r == s) continue;
                //if(ss.count({min(r, s), max(r, s)})) continue;
                //ss.insert({min(r, s), max(r, s)});
                r--;s--;
                ad[r].PB({s, w});
                ad[s].PB({r, w});
        }

        priority_queue<pair<int, pii> > q;
        ll dis[100005];
        forn(i, n) dis[i] = 1e12;
        q.push({0, {0, 0}});
        dis[0] = 0;
        bool vis[100005];
        memset(vis, false, sizeof(vis));
        ll par[n];
        par[0] = 0;
        while(!q.empty()) {
                pii d = q.top().S;q.pop();
                if(vis[d.F]) continue;
                vis[d.F] = true;
                for(pair<int, int> u: ad[d.F]) {
                        if(dis[u.F] > dis[d.F] + u.S) {
                                dis[u.F] = dis[d.F] + u.S;
                                par[u.F] = d.F;
                                q.push({-dis[u.F], {u.F, d.F}});
                        }
                }
        }
        vector<int> ans;
        ll p = n-1;
        while(par[p] != p) {
                assert(p >= 0 && p < n);
                ans.PB(p+1);
                p = par[p];
        }
        ans.PB(1);
        reverse(ans.begin(), ans.end());
        disp(ans);

}*/
void go1() {
        int n, k,i, j;
        in2(n, k);

        int a[n];
        forn(i, n) cin >> a[i];
        int ans = 0, mn = 1e9;
        int anss = 0;
        forn(i, k) ans += a[i];
        mn = ans;
        forsn(i,k, n) {
                ans += a[i];
                ans -= a[i-k];
                if(mn >= ans) {
                        mn = ans;
                        anss = i-k;
                }
        }
        anss++;
        cout << anss << ln;

}

void go3() {
        int n;
        cin >> n;
        cout << 1000 - n % 1000 - 1000*(n%1000 == 0) << ln;
        return;
        int i, j, k;
        string a[n];
        map<string, int> m;
        forn(i, n) {
                cin >> a[i];
                ++m[a[i]];
        }
        out3("AC", "x", m["AC"]);
        out3("WA", "x", m["WA"]);
        out3("TLE", "x", m["TLE"]);
        out3("RE", "x", m["RE"]);
}

int main(){
        fio;
        //freopen("b1.in","r",stdin);freopen("output.in","w",stdout);
        ll tt = 1;
/*

        cin >> tt;


        //*/
        while(tt--){
                go3();
        }

        return 0;
}

Measured memory_bytes: 3700