#include <iostream>
using namespace std;

int main() {
    int x = 0;
    int n = 0;
    int res = 0;

    cin >> x >> n;

    res = (x + n - 1) % 7 + 1;

    cout << res;

    return 0;
}