import java.util.Scanner; import java.lang.String; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int n=sc.nextInt(); n=n%7; if(x+n<=7) { System.out.println(x+n); }else{ System.out.println((x+n)%7); } } }