import java.util.Scanner object Main extends App { val sc = new Scanner(System.in) val n = sc.nextLong val a = "285714" println(a(((n + 5l) % 6).toInt)) }