#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db double
#define bo bool
#define vo void
#define ch char
#define ll long long
#define str string
#define re return
using namespace std;
str nhan(const str &n1,const str &n2)
{
ll l1=n1.size(),l2=n2.size(),i,j,tich,tong;
str ans;
vector<ll> res(l1+l2,0);
for(i=l1-1;i>=0;i--)
{
for(j=l2-1;j>=0;j--)
{
tich=(n1[i]-'0')*(n2[j]-'0');
tong=tich+res[i+j+1];
res[i+j+1]=tong%10;
res[i+j]+=tong/10;
}
}
for(ll i:res) if(!(ans.empty()&&i==0)) ans.push_back(i+'0');
re ans;
}
str chia(const str &n1, const str &n2)
{
ll m,t;
str res="",c="";
for(ch i : n1)
{
c+=i;
m=stoi(c);
t=stoi(n2);
res+=(m/t)+'0';
c=to_string(m%t);
}
size_t st=res.find_first_not_of('0');
if(st==str::npos) re "0";
re res.substr(st);
}
str mod(const str& n1,const str& n2)
{
ll div=0,m=0;
for(ch c : n2) div=div*10+(c-'0');
for(ch c : n1) m=(m*10+(c-'0'))%div;
re to_string(m);
}
int main()
{
faster
ll n;
cin>>n;
str s=to_string(n),s1=to_string(n+1),s2=to_string(n+2);
s=nhan(s,s1);
s=nhan(s,s2);
s=chia(s,"6");
cout<<mod(s,"2004010501");
re 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBmYXN0ZXIgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTtjaW4udGllKDApO2NvdXQudGllKDApOwojZGVmaW5lIGRiIGRvdWJsZQojZGVmaW5lIGJvIGJvb2wKI2RlZmluZSB2byB2b2lkCiNkZWZpbmUgY2ggY2hhcgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHN0ciBzdHJpbmcKI2RlZmluZSByZSByZXR1cm4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RyIG5oYW4oY29uc3Qgc3RyICZuMSxjb25zdCBzdHIgJm4yKQp7CiA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