시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 154 50 43 38.053%

문제

상근이는 숙제가 너무 하기 싫어서, 숙제 한 달치를 걸고 창영이와 게임을 하기로 했다. 진 사람은 한 달동안 숙제 두 명분을 해야 한다. 상근이는 영리하게 자신이 어렸을 때, 하던 게임을 하자고 했다. 창영이는 흔쾌히 수락했다.

이 게임을 하기 위해서는 주사위가 필요하다. 주사위는 왼쪽 그림과 같이 생겼다. 마주보는 면에 써 있는 숫자의 합은 항상 7이다. 즉, 6은 1, 5는 2, 4는 3은 마주보는 면이다.

그 다음, 한 칸의 크기가 주사위의 한 면과 같은 표를 그린다. 이 표의 크기는 R행 C열이다. 주사위는 가장 처음에 왼쪽 위 칸에 있다. 윗 면에는 숫자 1이 있고, 오른쪽 면에는 숫자 3이 있다. 이제 다음과 같이 주사위를 굴린다.

1. 주사위를 마지막 열에 도착하기 전까지 오른쪽으로 굴린다.

2. 주사위를 아래줄로 한 칸 굴린다.

3. 주사위를 첫 번째 열에 도착하기 전까지 왼쪽으로 굴린다.

4. 2단계와 비슷하게 주사위를 한 칸 아래로 굴린다.

상근이는 위와 같은 단계를 할 수 있을 때 까지, 즉, 마지막 줄까지 반복한다. 주사위가 어떤 칸에 도착하면, 창영이는 주사위 윗 면의 숫자를 적는다. 마지막에, 지금까지 적은 숫자를 모두 더한 다음, 상근이에게 물어본다.

상근이는 정답을 말할 것이고, 이 숫자가 창영이가 더한 합과 같다면 상근이가 이긴다. 상근이는 잠시 머뭇거리다가 정답을 말했다. 이제 창영이는 이 정답이 맞는지 확인해야 한다. R과 C가 주어졌을 때, 윗 면의 합을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 R과 C가 주어진다. (1 ≤ R, C ≤ 100,000)

출력

첫째 줄에 정답을 출력한다.

예제 입력 1

3 2

예제 출력 1

19

힌트

1 4
1 5
3 5
W3sicHJvYmxlbV9pZCI6IjI4MTgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJ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