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 dis 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).

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'.
Print the only integer x — the number of moves permitted for the king.
e4
8
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
String string = scanner.nextLine();
char column = string.charAt(0);
char row = string.charAt(1);
int R = Integer.parseInt(string.substring(1));
if((column == 'a' && R == 1) || (column == 'h' && R == 8) || (column == 'a' && R == 8) || (column == 'h' && R == 1)){
System.out.println(3);
}else if(column == 'a' || column == 'h' || R == 1 || R == 8){
System.out.println(5);
}else{
System.out.println(8);
}
}
}