#include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int M, D; cin >> M >> D; cout << (M == 4 && D == 1 ? -1 : M + D) << "\n"; }