import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNextBigInteger()){
BigInteger a = in.nextBigInteger();
if(a.mod(BigInteger.valueOf(3)).equals(BigInteger.valueOf(0)))
System.out.println(0);
else
System.out.println(1);
}
}
}
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNextBigInteger()){
BigInteger a = in.nextBigInteger();
if(a.mod(BigInteger.valueOf(3)).equals(BigInteger.valueOf(0)))
System.out.println(0);
else
System.out.println(1);
}
}
}