#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>
#include<deque>
#include<string>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#include<set>
#define ws " "
#define nl "\n"
#define tc ll test; cin>>test; while(test--)
#define f(i, a, b) for(ll i = a; i<b; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
using namespace std;

#define pid pair<int, double>
bool compare(pid a, pid b)
{
	//for descending order replace with a.roll >b.roll
   if(a.ss < b.ss)
        return 1;
	else
		return 0;
}


void fillPrefixSum(ll arr[], int n, ll prefixSum[])
{
    prefixSum[0] = arr[0];
    for (int i = 1; i <n; i++)
        prefixSum[i] = prefixSum[i-1] + arr[i];

}

void SieveOfEratosthenes(ll n, bool prime[], bool primesquare[], ll a[])
{
    for (ll i = 2; i <= n; i++)
        prime[i] = true;
    for (ll i = 0; i <= (n * n + 1); i++)
        primesquare[i] = false;
    prime[1] = false;

    for (ll p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            for (ll i = p * 2; i <= n; i += p)
                prime[i] = false;
        }
    }

    ll j = 0;
    for (ll p = 2; p <= n; p++) {
        if (prime[p]) {
            a[j] = p;

            primesquare[p * p] = true;
            j++;
        }
    }
}

ll countDivisors(ll n)
{
    if (n == 1)
        return 1;

    bool prime[n + 1], primesquare[n * n + 1];

    ll a[n]; // for storing primes upto n
    SieveOfEratosthenes(n, prime, primesquare, a);

    ll ans = 1;

    for (ll i = 0;; i++) {
        if (a[i] * a[i] * a[i] > n)
            break;
        ll cnt = 1; // cnt is power of prime a[i] in n.
        while (n % a[i] == 0) // if a[i] is a factor of n
        {
            n = n / a[i];
            cnt = cnt + 1; // incrementing power
        }

        ans = ans * cnt;
    }
    if (prime[n])
        ans = ans * 2;

    // Second case
    else if (primesquare[n])
        ans = ans * 3;

    // Third casse
    else if (n != 1)
        ans = ans * 4;

    return ans; // Total divisors
}

bool checkLast(ll n)
{
    if(n%10==0)
        return true;
    return false;

}
bool checkPrime(ll n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}


struct parts{

int start, en;
//bool included;

};

struct c{

ll num;
ll type;

};

int checkFor(ll m, c arr[], int n)
{
    f(i, 0, n)
    {
        if(arr[i].num==m)
            return i;
    }
}

ll answer = 0, ct = 0;

ll getSum(ll n)
{
   ll sum = 0;
   while (n != 0)
   {
       sum = sum + n % 10;
       n = n/10;
   }
   return sum;
}
void solve()
{

    ll n;
    cin>>n;

    n = n%1000;

    if(n==0)
        cout<<0<<nl;
    else
    cout<<1000-n<<nl;
}







int main()
{
    fastIO;


 // tc
    solve();
}



  /*  if(rCount == 0)
    {

        while(s[i]!='\0')
        {
            ll i = 0;
            if((s[i]=='.'&&s[i+1]=='L')||(s[0]=='L'))
            {
                t = i+1;
                break;
            }
            i++;
        }
        i++;
        while(s[i]!='\0')
        {
            if((s[i]=='.'&&s[i-1]=='L')||(s[n-1]=='L'))
            {
                {
                    s = i+1;
                    break;
                }
            }
            i++;
        }

    }
    else if(lCount == 0)
    */


Measured memory_bytes: 3652