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

<image> King moves from the position e4

Input

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

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

Example

Input

e4


Output

8
import java.util.*;
import java.io.*;
import java.math.BigInteger;
/*
3
0 -4 -3
2
2 3

5
11 21 30 40 50
3
1 2 3

 */
public class A 
{
	public static void main(String[] arg) throws Exception
	{
		new A();
	}
	
	public A() throws Exception
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = in.next();
		int ret = 8;
		if(s.charAt(0) == 'a' || s.charAt(0) == 'h') ret -= 3;
		if(s.charAt(1) == '1' || s.charAt(1) == '8') ret -= 3;
		if(s.equals("a8") || s.equals("h8") || s.equals("a1") || s.equals("h1")) ret++;
		System.out.println(ret);
		in.close(); out.close();
	}
	class Pair implements Comparable<Pair>
	{
		long v;
		int idx;
		public Pair(long a, int b)
		{
			v = a;
			idx = b;
		}
		public int compareTo(Pair p)
		{
			return Long.compare(v, p.v);
		}
		public String toString()
		{
			return v + " " + idx;
		}
	}
	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}
