#include <iostream>
#include <iomanip>
using namespace std;
int main() {
long long B, M;
cin >>B,M;
long long int sum=(M%8) ;
long long int sum1=(B%6) ;
cout << sum+sum1 ;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKSB7CmxvbmcgbG9uZyAgQiwgTTsKCmNpbiA+PkIsTTsKbG9uZyBsb25nIGludCBzdW09KE0lOCkgOwpsb25nIGxvbmcgaW50IHN1bTE9KEIlNikgOwpjb3V0IDw8IHN1bStzdW0xIDsKICAKCiByZXR1cm4gMDsKCn0KCg==