https://www.acmicpc.net/problem/1783
#include <iostream>
using namespace std;
long long n, m;
// 병든 나이트
long long solution(){
long long answer = 1;
if(m < 7 || n < 3){
if(n >= 3) answer = m;
else if(n == 2) answer += (m-1)/2;
if(answer >4)
answer = 4;
}else answer = m -2;
return answer;
}
#include <cstdio>
int N, M, r;
int main() {
scanf("%d %d", &N, &M);
if (N == 1) r = N;
else if (N == 2) M < 7 ? r = (M + 1) / 2 : r = 4;
else {
if (M < 5) r = M;
else if (M > 6) r = M - 2;
else r = 4;
}
printf("%d\n", r);
}