static immutable MOD = 4;
static immutable MOD_OVERAL = 5;
static immutable MODS = [
	[1, 1, 1, 1],
	[1, 2, 4, 3],
	[1, 3, 4, 2],
	[1, 4, 1, 4]
];

uint solve(const string n) {
	uint sum = 0;
	foreach (ch; n) {
		if (ch < '0' || ch > '9') {break;}
		sum = ( (sum * 10) + (ch - '0') ) % MOD;
	}

	sum %= MOD;
	uint res = 0;
	foreach (curMod; MODS) {
		res += curMod[sum];
	}

	return res % MOD_OVERAL;
}

unittest {
	assert(4 == solve("4"));
	assert(0 == solve("124356983594583453458888889"));
	assert(4 == solve("0"));
	assert(0 == solve("5"));
	assert(0 == solve("6"));
	assert(0 == solve("7"));
	assert(4 == solve("8"));
}

int main(string[] argv) {
	import std.stdio;
	writeln(solve(readln));
    return 0;
}
