Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:
(1
N? +? 2
N? +? 3
N? +? 4
N)
MoD5
For given valueN. Fedya managed to complete the task. Can you? Note that given numberNCan be extremely large (e.g. It can exceed any integer type of your programming language ).
Input
The single line contains a single integerN(0? ≤?N? ≤? 10105). The number doesn' t contain any leading zeroes.
Output
Print the value of the expression without leading zeros.
Sample test (s) Input
4
Output
4
Input
124356983594583453458888889
Output
0
Note
OperationX mod yMeans taking remainder after DivisionXByY.
Note to the first sample:
He does not understand the Fermat theorem. After the table is typed, 4 is output when n % 4 = 0,
The rest outputs 0, but n data is too big. We know that the number above 100 can be broken down into 100 * X + Y. You only need to consider y, that is, you only need to consider the last two. This is easy to handle. Read the string to get the last two modulo operations.
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<limits.h>#include<cmath>using namespace std;const int maxn=1e6;char s[maxn];int main(){ while(~scanf("%s",s)) { int len=strlen(s); int sum=0; sum+=s[len-1]-'0'+(s[len-2]-'0')*10; if(sum%4==0) cout<<4<<endl; else cout<<0<<endl; } return 0;}