#include <iostream>
using namespace std;

int main() {
    int X,N;
    cin>>X>>N;
    if((X+N)%7==0)
    cout<<7;
    else
     cout<<(X+N)%7;
    //printf("%d\n",(Week + Day - 1) % 7 + 1);
}
// 64 位输出请用 printf("%lld")