import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
//(-2,-1)(-2,1)(2,-1)(2,1)(-1,-2)(-1,2)(1,-2)(1,2)
int[] dx = {-2,-2,2,2,-1,-1,1,1};
int[] dy = {-1,1,-1,1,-2,2,-2,2};
//문자형 숫자를 숫자로 변환
int x = s.charAt(1) - '0';
//문자 알파벳을 숫자로 변환(a = 1로)
int y = s.charAt(0) - 'a' + 1;
int count = 0;
//8가지 좌표 중 이동 가능한 것 체크
for(int i = 0; i < 8; i++) {
int nx = x + dx[i];
int ny = y + dy[i];
System.out.println("nx : " + nx);
System.out.println("ny : " + ny);
if(nx >= 1 && ny >= 1 && nx <= 8 && ny <= 8) {
count++;
continue;
}
}
System.out.println(count);
}
}