跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2174. Chess

  • ID: 2180
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:基础
  • 上传者:
  • 枚举
  • 模拟
  • 数学
  • 算法思想
  • 编程与模拟
  • 基础
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Chess

题目描述

B. Chess
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Two chess pieces, a rook and a knight, stand on a standard chessboard 8×8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.

Your task is to find the number of ways to place another knight on the board so that none of the three pieces on the board beat another one. A new piece can only be placed on an empty square.

Input

The first input line contains the description of the rook's position on the board. This description is a line which is 2 in length. Its first symbol is a lower-case Latin letter from a to h, and its second symbol is a number from 1 to 8. The second line contains the description of the knight's position in a similar way. It is guaranteed that their positions do not coincide.

Output

Print a single number which is the required number of ways.

Examples
Input
a1
b2
Output
44
Input
a8
d4
Output
38

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1778 题。保留原作者与原赛事署名。