#include <iostream>
using namespace std;

int main() {
    int x, n;
    scanf("%d%d", &x, &n);
    x = (x + n) % 7;
    printf("%d", x ? x : 7);
}