#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
typedef long double ld;
typedef string ss;
typedef vector<long long> vll;
typedef stack<ll> skll;
typedef pair<char, ll> pci;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef map<char, ll> mcl;
#define pb push_back
#define conti continue;
#define fi first
#define se second
#define pr(a, b) pb(make_pair(a, b))
#define mkp(a, b) make_pair(a, b)
#define nl '\n'
#define all(v) v.begin(), v.end()
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define fost(i, a, b, d) for (ll i = a; i < b; i += d)
#define ofst(i, a, b, d) for (ll i = a; i > b; i -= d)
#define forb(i, a, b) for (int i = a; i < b; i++)
#define fon(i, a, b) for (int i = a; i >= b; i--)
#define fo(i, n) for (int i = 0; i < n; i++)
#define itmp(mp) for (auto it = mp.begin(); it != mp.end(); it++)
#define start_clock() auto start_time = std::chrono::high_resolution_clock::now();
#define measure() \
auto end_time = std::chrono::high_resolution_clock::now(); \
cerr << (end_time - start_time) / std::chrono::milliseconds(1) << "ms" << endl;
#define yes cout << "YES" << nl;
#define no cout << "NO" << nl;
/*-----------------------------debug----------------------------*/
vector<string> vec_splitter(string s)
{
s += ',';
vector<string> res;
while (!s.empty())
{
res.push_back(s.substr(0, s.find(',')));
s = s.substr(s.find(',') + 1);
}
return res;
}
void debug_out(
vector<string> __attribute__((unused)) args,
__attribute__((unused)) int idx,
__attribute__((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T)
{
if (idx > 0)
cerr << ", ";
else
cerr << "Line(" << LINE_NUM << ") ";
stringstream ss;
ss << H;
cerr << args[idx] << " = " << ss.str();
debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
/*-----------------------------debug----------------------------*/
/*-----------------------------printfs----------------------------*/
void parr(ll a[], ll n)
{
for (ll i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << endl;
}
void pvec(vector<ll> v)
{
for (ll i = 0; i < v.size(); i++)
{
cout << v[i] << " ";
}
cout << endl;
}
struct custom_hash
{
static uint64_t splitmix64(uint64_t x)
{
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
{
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
/*----------------------------printfs----------------------------*/
/*----------------------------mint_stuff----------------------------*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
x = 1, y = 0; // xa+yb=a at all times
ll q, x1 = 0, y1 = 1; // x1a+y1b=b at all times
while (a && b)
{
if (a > b)
{
q = a / b;
x -= q * x1;
y -= q * y1;
a -= q * b;
}
else
{
q = b / a;
x1 -= q * x;
y1 -= q * y;
b -= q * a;
}
}
if (a == 0)
{
x = x1;
y = y1;
return b;
}
return a;
}
const ll mod = 4;
struct mint
{
ll x;
mint() : x(0) {}
mint(ll y)
{
if (y >= 0 && y < mod)
x = y;
else
{
x = y % mod;
if (x < 0)
x += mod;
}
}
mint operator-() { return mint(-x + mod); }
mint operator~() const
{
ll a, b;
extgcd(x, mod, a, b);
return a;
}
mint &operator+=(const mint &a)
{
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint &a)
{
if ((x -= a.x) < 0)
x += mod;
return *this;
}
mint &operator*=(const mint &a)
{
x = (x * a.x) % mod;
return *this;
}
mint &operator/=(const mint &a)
{
this->operator*=(~a);
return *this;
}
mint operator++()
{
++x;
if (x == mod)
x = 0;
return (*this);
}
mint operator++(int)
{
x++;
if (x == mod)
x = 0;
return mint(x - 1);
}
mint operator--()
{
--x;
if (x == -1)
x = mod - 1;
return (*this);
}
mint operator--(int)
{
x--;
if (x == -1)
x = mod - 1;
return mint(x + 1);
}
mint pow(ll b) const
{
mint res(1);
mint a(*this);
while (b)
{
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
mint operator+(const mint &a) const { return mint(*this) += a; }
mint operator-(const mint &a) const { return mint(*this) -= a; }
mint operator*(const mint &a) const { return mint(*this) *= a; }
mint operator/(const mint &a) const { return mint(*this) /= a; }
bool operator<(const mint &a) const { return x < a.x; }
bool operator<=(const mint &a) const { return x <= a.x; }
bool operator>(const mint &a) const { return x > a.x; }
bool operator>=(const mint &a) const { return x >= a.x; }
bool operator==(const mint &a) const { return x == a.x; }
bool operator!=(const mint &a) const { return x != a.x; }
friend istream &operator>>(istream &is, mint p) { return is >> p.x; }
friend ostream &operator<<(ostream &os, mint p) { return os << p.x; }
};
/*----------------------------mint_stuff----------------------------*/
ll gcd(ll a, ll b)
{
if (a == 0)
return b;
ll r = b % a;
if (r == 0)
return a;
else
return gcd(r, a);
}
long long nCr(int n, int r, int M)
{
if (r > n - r)
r = n - r;
long long ans = 1;
int i;
for (i = 1; i <= r; i++)
{
ans *= n - r + i;
ans /= i;
}
return ans;
}
ll binPow(ll a, ll b, ll m)
{
a %= m;
ll ans = 1;
while (b != 0)
{
if (b & 1)
ans = (ans * a) % m;
a = (a * a) % m;
b = b >> 1;
}
// O(log2(k))
return ans;
}
ll binMul(ll n, ll k, ll m)
{
ll ans = 0;
while (k != 0)
{
if (k & 1)
ans = (ans + n) % m;
n = (2 * n) % m;
k = k >> 1;
} // O(log2(k))
return ans;
}
/*modInverse: binPow(n,M-2,M)*/
/*For very large Expo, use b=b%(M-1),where M is a prime number and a^b%M is req*/
/*---------------------------------- NUMBER THEORY--------------------------------*/
// ll toBase9(ll n){
// }
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("inputf.in", "r", stdin);
freopen("outputf.in", "w", stdout);
freopen("debug.txt", "w", stderr);
#endif
int ttt = 1;
// ll zz = -1;
// cin >> ttt;
while (ttt--)
{
cout << setprecision(30);
map<ll, ll> mp, cnt;
ll n, max = 0, orig, min = INF, sum = 0, f = 0;
cin >> n;
// n = ttt;
// cout <<"n"<< n << nl;
ll ans = 0;
vll v;
orig = n;
// assert(n != -1);
while (n / 9 != 0)
{
// cout << n << nl;
v.pb(n % 9);
n /= 9;
}
if (n % 9 != 0)
v.pb(n % 9);
// reverse(all(v));
// pvec(v);
ll z = 0;
ll x = 0;
for (auto p : v)
{
x += p;
// if(p==0){
// z++;
// conti
// }
ll p9 = (ll)pow(9, z); //
ans += (((((p * (p - 1)) / 2) % 4) * (p9 % 4))) % 4; //
ans += ((p % 4) * ((orig % (p9) + 1) % 4)) % 4;
// cout << (p9*9) << nl;
// sum += ((p+1) * p9) % 4;
z++;
}
cout << (ans) % 4 << nl;
// if ((zz != ans % 4)&&zz!=-1)
// {
// no return 0;
// }
// zz = (4 + (ans - x) % 4) % 4;
}
return 0;
}
/*
1. Always be cautious of 'n==1 and n==2' in Number theory Ques.
2. Always treat your edge cases distinctly, never try to indulge them in usual loops!
3. Always check back and forth for equality cases!
4. always add a break after f++;
5. always sort before using upper_bound
6. any changing DS is best declared as global and cleared after each test case!
7. Don't overthink, at first just try to go for the simplemost approach, use Implementations.md for reference!
*/