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