main(n){scanf("%d", &n);printf("%d\n",(n=3-n%3)==3?0:n);}