#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
//#define lim 100001

using namespace std;
ll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
int max3(int a, int b, int c) { return max(a, max(c, b)); }
int gcd(int a, int b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
ll power(ll a, ll n)
{
    if (n == 1)
        return a;
    else if (n == 0)
        return 1;
    else
    {
        ll r = power(a, n / 2);
        if (n % 2 == 0)
            return r * r;
        else
            return r * a * r;
    }
}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector<vector<int>> &v, vi &check, int start)
{
    check[start - 1] = 1;
    repj(j, 0, v[start - 1].size())
    {
        if (!check[v[start - 1][j] - 1])
        {
            dfs(v, check, v[start - 1][j]);
        }
    }
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//works under 2 till 1e12

int printDivisors(int n)
{
    // Note that this loop runs till square root
    int num=0;
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            // If divisors are equal, print only one
            if (n / i == i){
                if(i % 2 == 1){
                        //if(isPrime(i))
                            num++;
                }
            }

                else{
                    if(i%2==1){
                        //if(isPrime(i))
                            num++;
                    }
                    if((n/i)%2==1){
                        //if(isPrime(n/i))
                            num++;
                    }

            } // Otherwise print both
        }
        }
    
    return num;
}

// Initializing the roots of the array and the size of the roots

void initialize(int Arr[], int N, int Size[])
{
    for (int i = 0; i < N; i++)
    {
        Arr[i] = i;
        Size[i] = 1;
    }
}

// To find the root of any single element

int root(int Arr[], int i)
{
    while (Arr[i] != i)
    {
        i = Arr[i];
    }
    return i;
}

// To connect the roots of union elemnts

void Union(int Arr[], int A, int B, int Size[])
{
    int root_A = root(Arr, A);
    int root_B = root(Arr, B);
    if(root_A!=root_B){
        if (Size[root_B] > Size[root_A])
        {
            Arr[root_A] = root_B;
            Size[root_B] += Size[root_A];
        }
        else
        {
            Arr[root_B] = root_A;
            Size[root_A] += Size[root_B];
        }
    }
}

// To check the connectivity of two elements

bool Find(int Arr[], int A, int B)
{
    if (root(Arr, A) == root(Arr, B))
        return true;
    else
        return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    int n = 1000;
    while(true){
        if(n>=t){
            n = n - t;
            break;
        }
        else{
            n += 1000;
        }
    }
    cout << n;

    return 0;
}

Measured memory_bytes: 3696