#include <stdio.h>
int main() {
    int x, N,c;
scanf("%d%d",&x,&N);
c=(x+N%7)%7;
if(c==0)
{
    c=7;
}
printf("%d",c);
    return 0;
}