#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	printf("%d", (3 - N % 3) % 3);
	fflush(stdout);
	return 0;
}