시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 (추가 시간 없음) 512 MB 0 0 0 0.000%

문제

It is game night and Alice and Bob are playing chess. After beating Bob at chess several times, Alice suggests they should play a chess variant instead called hexagonal chess. Although the game is very rarely played nowadays, Alice knows the rules very well and has obtained a hexagonal chessboard from her subscription to the magazine of Bizarre Artifacts for Playing Chess.

Figure H.1: The field naming of the hexagonal chess board and the directions in which a rook can move.

The hexagonal chess board, shown above, consists of 91 hexagonal cells arranged in the shape of a hexagon with side length 6 as depicted in the above diagrams. The board is divided into 11 columns, each called a file, and the files are labeled a to k from left to right. It is also divided into 11 v-shaped rows, each called a rank, which are labeled 1 to 11 from bottom to top. The unique cell in file x and rank y is then denoted by the coordinate xy. For example, rank 11 contains only a single cell f11 and rank 7 is occupied entirely by the black player’s pawns.

Alice begins by explaining how all the pieces move. The simplest piece is the rook, which can move an arbitrary positive number of steps in a straight line in the direction of any of its 6 adjacent cells, as depicted in the figure on the right. Bob immediately realises that the hexagonal rook already is more difficult to work with than its regular chess counterpart.

In order to attack one of the opponents pieces, it is useful to know which cells his rook can move to such that it attacks the opposing piece. The more of these cells there are, the more valuable the current position of his rook is. However, calculating this number is too much for Bob. After losing so many games of regular chess, Alice allows Bob to use a program to assist in his rook placement. While Alice explains the rest of the game you get busy coding.

As a small simplification, Bob will compute the number of ways his rook can move to the destination cell assuming there are no other pieces on the board, not even the piece he wants to attack.

입력

  • The input consists of one line, containing two different coordinates on the hexagonal chess board, the current positions of your rook and the piece you want to attack.

출력

Output a single integer, the number of ways the rook can move from its current position to the position of the piece it wants to attack in exactly two moves, assuming there are no other pieces on the board.

예제 입력 1

c4 h4

예제 출력 1

6

예제 입력 2

a1 a2

예제 출력 2

5