2190.King Moves

Time Limit: 1s Memory Limit: 256MB

The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.

Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).
2190_1.png King moves from the position e4

Input Format(From the terminal/stdin)

The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.

Output Format(To the terminal/stdout)

Print the only integer x - the number of moves permitted for the king.

Sample Input

Copy
e4
  \n

Sample Output

Copy
8
 \n

Submit

请先 登录

© 2025 FAQs