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).  King moves from the position e4

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.

import java.util.Scanner;

public class king {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		String cd=sca.next();
		char c = cd.charAt(0);
		byte d =(byte)((byte)cd.charAt(1)-48);
		switch (cd) {
		case "a1" : case "a8" : case "h1" : case "h8":
			System.out.println(3);
			break;
		default :
			switch (c) {
			case 'a' : case 'h' :
				System.out.println(5);
				break;
			default :
				switch (d) {
				case 1 : case 8 :
					System.out.println(5);
					break;
				default :
					System.out.println(8);
				}
			}
		}
	}

}

import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String pos = sc.next();

		String[] pos2 = pos.split("");

		if (pos2[0].equals("a") && pos2[1].equals("1")) {
			System.out.println(3);
		} else if (pos2[0].equals("a") && pos2[1].equals("8")) {
			System.out.println(3);
		} else if (pos2[0].equals("h") && pos2[1].equals("1")) {
			System.out.println(3);
		} else if (pos2[0].equals("h") && pos2[1].equals("8")) {
			System.out.println(3);
		} else if (pos2[0].equals("a")) {
			System.out.println(5);
		} else if (pos2[0].equals("h")) {
			System.out.println(5);
		} else if (pos2[1].equals("1")) {
			System.out.println(5);
		} else if (pos2[1].equals("8")) {
			System.out.println(5);
		} else {
			System.out.println(8);
		}

		sc.close();

	}

}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputStream inputstream = System.in;
		OutputStream outputstream = System.out;
		InputReader in = new InputReader(inputstream);
		PrintWriter out = new PrintWriter(outputstream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testN, InputReader in, PrintWriter out) {
			String str = in.next();
			boolean p = str.charAt(0) == 'a';
			boolean q = str.charAt(0) == 'h';
			boolean r = str.charAt(1) == '1';
			boolean s = str.charAt(1) == '8';
			if (p || q) {
				if (r || s) {
					out.println(3);
				}
				else {
					out.println(5);
				}
			}
			else {
				if (r || s) {
					out.println(5);
				}
				else {
					out.println(8);
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public short nextShort() {
			return Short.parseShort(next());
		}

		public byte nextByte() {
			return Byte.parseByte(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public boolean hasNext() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) {
						return false;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return true;
		}
	}
}

import java.util.Scanner;

/**
 *
 * @author toshiba
 */
public class Tests {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
         if((str.charAt(0) == 'a' && str.charAt(1) == '1')
                 || (str.charAt(0) == 'a' && str.charAt(1) == '8')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '1')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '8'))
            System.out.println(3);
         else if(
                 ((str.charAt(0) == 'a' || str.charAt(0) == 'h')
                 && (str.charAt(1) >= 49 || str.charAt(1) <= 56)))
                 System.out.println(5);
         else if (((str.charAt(0) >= 'a' || str.charAt(0) <= 'h')
                 && (str.charAt(1) == 49 || str.charAt(1) == 56)))
             System.out.println(5);
         else
             System.out.println(8);
        }
    }

import java.util.Scanner;

public class KingMoves {

    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String cd = input.next();
        String c = String.valueOf(cd.charAt(0));
        String d = String.valueOf(cd.charAt(1));

        if (c.equals("a") || c.equals("h")) {
            if (d.equals("1") || d.equals("8")) System.out.println("3");
            else System.out.println("5");
        } else if (d.equals("1") || d.equals("8")) System.out.println("5");
        else System.out.println("8");
    }
}

//king moves
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

public class KingMoves {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//testSet();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		char c = input.charAt(0);
		char d = input.charAt(1);
		boolean cond1 = c == 'a' || c== 'h';
		boolean cond2 = d == '1' || d== '8';
		int moves = 8;
		if(cond1 && cond2) moves = 3;
		else if(cond1 || cond2) moves = 5;
		System.out.println(moves);
	}

	public static void testSet() throws UnsupportedEncodingException {
		String data = "h2";
		InputStream testInput = new ByteArrayInputStream( data.getBytes("UTF-8") );
		System.setIn(testInput);
	}

}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.lang.reflect.Array;
import java.util.Objects;

public class Main {
    public void exec() {
        String x = stdin.nextString();
        int a = x.charAt(0)-'a';
        int b = x.charAt(1)-'1';

        int ans = 0;
        for (int i = -1; i <= 1; i++) {
            for (int j = -1; j <= 1; j++) {
                if (i==0&&j==0) continue;
                if (0<=a+i && a+i<8 && 0<=b+j && b+j<8) ans++;
            }
        }
        stdout.println(ans);
    }

    private static final Stdin stdin = new Stdin(System.in);
    private static final Stdout stdout = new Stdout(System.out);
    private static final Stderr stderr = new Stderr(System.err, true);

    public static void main(String[] args) {
        try {
            new Main().exec();
        } finally {
            stdout.flush();
        }
    }

    // ASCII ONLY
    public static class Stdin {
        private InputStream in;
        private byte[] buf;
        private int ptr;
        private int len;

        public Stdin(InputStream in) {
            this.in = in;
            this.buf = new byte[1024];
            this.ptr = 0;
            this.len = 0;
        }

        public String nextString() {
            StringBuilder sb = new StringBuilder();
            byte b;
            while ((b = read()) != -1) {
                sb.appendCodePoint(b);
            }
            return sb.toString();
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public double nextDouble() {
            return Double.parseDouble(nextString());
        }

        public long nextLong() {
            boolean negative = false;
            int x = 0;

            byte b = read();
            if (b == '-') {
                negative = true;
            } else {
                x += b-'0';
            }

            while ((b=read()) != -1) {
                x *= 10;
                x += b-'0';
            }

            return negative ? -x : x;
        }

        private byte read() {
            byte b = readByte();
            if (b == '\r') {
                readByte(); // LFを読み飛ばす
                return -1;
            } else if (b == '\n' || b == ' ') {
                return -1;
            } else {
                return b;
            }
        }

        private byte readByte(){
            if (len == ptr) {
                try {
                    ptr = 0;
                    len = in.read(buf);
                    if (len == -1) return -1;
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return buf[ptr++];
        }

        public String[] nextStringArray(int n) {
            String[] a = new String[n];
            for (int i = 0; i < n; i++) a[i] = nextString();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) {
            double[] a = new double[n];
            for (int i = 0; i < n; i++) a[i] = nextDouble();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    public static class Stdout {
        private PrintWriter stdout;

        public Stdout(PrintStream stdout) {
            this.stdout =  new PrintWriter(stdout, false);
        }

        public void println(Object ... objs) {
            for (int i = 0, len = objs.length; i < len; i++) {
                stdout.print(objs[i]);
                if (i != len-1) stdout.print(' ');
            }
            stdout.println();
        }

        public void flush() {
            stdout.flush();
        }
    }

    public static class Stderr {
        private PrintWriter stderr;
        private boolean debug;

        public Stderr(PrintStream stderr, boolean debug) {
            this.stderr =  new PrintWriter(stderr, false);
            this.debug = debug;
        }

        public void println(Object ... objs) {
            if (!debug) return ;

            stderr.print("DEBUG: ");
            for (int i = 0, len = objs.length; i < len; i++) {
                stderr.print(deepToString(objs[i]));
                if (i != len-1) stderr.print(' ');
            }
            stderr.println();
            stderr.flush();
        }

        private String deepToString(Object o) {
            if (o == null) {
                return "null";
            }

            // 配列の場合
            if (o.getClass().isArray()) {
                int len = Array.getLength(o);
                String[] tokens = new String[len];
                for (int i = 0; i < len; i++) {
                    tokens[i] = deepToString(Array.get(o, i));
                }
                return "{" + String.join(", ", tokens) + "}";
            }

            return Objects.toString(o);
        }
    }
}

import java.util.*;

public class KingMoves {
	public static void main(String[] agrs) {
		Scanner input = new Scanner(System.in);
		String s;

		s = input.nextLine();

		String column = s.substring(0, 1);
		String row = s.substring(1,2);

		if (column.equals( "a") || column.equals("h")) {
			if (row.equals("1") || row.equals( "8")) {
			System.out.println(3);
			}
			else {
			System.out.print(5);
			}
		}
		else {
			if (row.equals("1") || row.equals("8")) {
				System.out.println(5);
			}
			else {
			System.out.println(8);
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter; // PrintWriter
import java.math.BigDecimal;
import java.math.BigInteger; // BigInteger, BigDecimal
import java.util.StringTokenizer; // StringTokenizer, ArrayList

public class Main {
    FastReader in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        in = new FastReader(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    void solve() {
        String pos = in.nextLine();
        int x = pos.charAt(0) - 'a';
        int y = Integer.valueOf(String.valueOf(pos.charAt(1))) - 1;
        int res = 8;
        if (isBound(x) && isBound(y)) {
            res = 3;
        } else if (isBound(x) || isBound(y)) {
            res = 5;
        }

        out.println(res);
    }

    private boolean isBound(int x) {
        return x == 0 || x == 7;
    }

    // -----------------------------------------------------
    void runWithFiles() {
        in = new FastReader(new File("input.txt"));
        try {
            out = new PrintWriter(new File("output.txt"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        solve();
        out.close();
    }

    class FastReader {
        BufferedReader br;
        StringTokenizer tokenizer;

        public FastReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public FastReader(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
                tokenizer = null;
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}

import java.util.*;
public class eduRound {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		char row = input.charAt(0);
		int col = input.charAt(1)-'0';
		int sides = 0;
		if (row=='a' || row=='h') {
			sides++;
		}
		if (col==1 || col==8) {
			sides++;
		}
		switch (sides) {
		case 0:
			System.out.println(8);
			break;
		case 1:
			System.out.println(5);
			break;
		case 2:
			System.out.println(3);
			break;
		}
	}

}

import java.util.*;

public class KingMoves {
    public static void main(String[] args) {

        Scanner kbd = new Scanner (System.in);
        int counter = 0;
        String input = kbd.nextLine();
        char c = input.charAt(0);
        int x = 0;
        String r = input.charAt(1) + "";
        int y = Integer.parseInt(r) + 0;

        switch (c) {
            case 'a': x = 1;break;
            case 'b': x = 2;break;
            case 'c': x = 3;break;
            case 'd': x = 4;break;
            case 'e': x = 5;break;
            case 'f': x = 6;break;
            case 'g': x = 7;break;
            case 'h': x = 8;break;
        }
        int east = x;
        int west = x;
        int nEastX = x;
        int sEastX = x;
        int nWestX = x;
        int sWestX = x;
        int north = y;
        int south = y;
        int nEastY = y;
        int sEastY = y;
       	int nWestY = y;
        int sWestY = y;

            	east++;
                if (east <= 8) {
                	counter++;
                }

                west--;
                if (west > 0) {
                	counter++;
                }

				north++;
                if (north <= 8) {
                	counter++;
                }

                south--;
                if (south > 0) {
                	counter++;
                }

                nEastY++;
                nEastX++;
                if(nEastX <= 8 && nEastY <= 8 ){
                	counter++;
                }

				nWestY++;
				nWestX--;
				if(nWestX > 0 && nWestY <= 8){
					counter++;
				}

				sEastY--;
				sEastX++;
				if(sEastX <= 8 && sEastY > 0){
					counter++;
				}

				sWestY--;
				sWestX--;
				if(sWestX > 0 && sWestY > 0){
					counter++;
				}

			System.out.println(counter);

    }

}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in=new Scanner(System.in);
        String a=in.next();
        String c=a.substring(0, 1);
        String r=a.substring(1, 2);

        int b;
        if((c.equals("h")&&(r.equals("8")||r.equals("1")))||(c.equals("a")&&(r.equals("8")||r.equals("1"))))b=3;
        else if (c.equals("h")||r.equals("8")||r.equals("1")||c.equals("a") )b=5;
        else b=8;
        System.out.println(b);

    }
}

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Solution solution = new Solution();
    solution.solve(in, out);
    out.close();
  }

  private static class Solution {
    final int[][] moves = {
        {1, -1},
        {1, 0},
        {1, 1},
        {0, -1},
        {0, 1},
        {-1, -1},
        {-1, 0},
        {-1, 1}
    };

    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      int count = 0;
      char r = cell.charAt(1);
      char c = cell.charAt(0);
      for (int[] move : moves) {
        char newRow = (char) (r + move[0]);
        char newCol = (char) (c + move[1]);
        if (isValidCell(newRow, newCol)) {
          count++;
        }
      }
      out.println(count);
    }

    boolean isValidCell(char r, char c) {
      return r >= '1' && r <= '8' && c >= 'a' && c <= 'h';
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.util.Scanner;

public class King_Moves {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        char arr[] = n.toCharArray();
        if (n.compareTo("a8") == 0 || n.compareTo("h1") == 0 || n.compareTo("h8") == 0 || n.compareTo("a1") == 0) {
            System.out.println("3");
        } else if (arr[0] == 'a' || arr[0] == 'h' || arr[1] == '8' || arr[1] == '1') {
            System.out.println("5");
        } else {
            System.out.println("8");
        }
    }

}

    import java.util.*;
    import java.lang.*;
    import java.io.*;

    public class S{
        public static void main(String[] args) {
		String s1;
		Scanner sc = new Scanner(System.in);
		String position = sc.nextLine();
		System.out.println(kingMoves(position));
	}

	public static int kingMoves(String position) {
		int x = Character.getNumericValue(position.charAt(0));
		int y = Character.getNumericValue(position.charAt(1));

		int moves =0;
		if( (x==10 || x==17) && (y==1 || y==8)) {
			moves+=3;
		}else if( (x>10 && x<17 && y==1) || (x>10 && x<17 && y==8) || (y>1 && y<8 && x==10) || (y>1 && y<8 && x==17)) {
			moves+=5;
		}else if(x>10 && x<17 && y>1 && y<8){
			moves+=8;
		}

		return moves;
	}
    }

import java.io.*;
import java.util.*;
import java.util.TreeSet;
import java.lang.*;
import java.text.DecimalFormat;
public class ab{
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		String z=in.next();
		char c=z.charAt(0),r=z.charAt(1);
		if(c=='a'||c=='h'){
			if(r=='1'||r=='8')
				System.out.println(3);
			else
				System.out.println(5);
		}
		else if(r=='1'||r=='8'){
			System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

import java.util.*;
import java.io.*;
import java.lang.Math;

public class solve
{
	// Read a String from the standard input using Scanner
	// public static void main(String[] args)
	// {
	// 	Scanner scanner = new Scanner(System.in);
	// 	ArrayList<Integer> nums = new ArrayList<Integer>();
	// 	for(String tok : scanner.nextLine().split(" ")){
	// 		nums.add(Integer.parseInt(tok));

	// 	}

	// 	System.out.println(nums);
	// 	scanner.close();

	// }
	public static void fun(String s){

		char c = s.charAt(0);
		char num = s.charAt(1);

		int ret = 8;
		boolean flag = false;
		if(c == 'a' || c == 'h'){
			ret -= 3;
			flag = true;
		}

		if(num == '1' || num == '8'){
			if(flag){
				ret -= 2;
			}else{
				ret -= 3;
			}

		}
		System.out.println(ret);
	}

	public static void main(String[] args){

		FastReader fr = new FastReader();
		String s = fr.nextLine();
		fun(s);

	}

	static class FastReader
	{
	    BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    	br = new BufferedReader(new
	                 InputStreamReader(System.in));
	    }
	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try{
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }
	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	    double nextDouble() {
	        return Double.parseDouble(next());
	    }
	    String nextLine() {
	        String str = "";
	        try{
	            str = br.readLine();
	        }
	        catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	    }
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Solution solution = new Solution();
    solution.solve(in, out);
    out.close();
  }

  private static class Solution {
    int[][] moves = {
        {1, -1},
        {1, 0},
        {1, 1},
        {0, -1},
        {0, 1},
        {-1, -1},
        {-1, 0},
        {-1, 1}
    };

    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      int count = 0;
      char r = cell.charAt(1);
      char c = cell.charAt(0);
      for (int[] move : moves) {
        char newR = (char) (r + move[0]);
        char newC = (char) (c + move[1]);
        if (isValid(newR, newC)) {
          count++;
        }
      }
      out.println(count);
    }

    boolean isValid(char r, char c) {
      return r >= '1' && r <= '8' && c >= 'a' && c <= 'h';
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.io.*;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}

class Task {

    public void solve(InputReader in, OutputWriter out) {
        String position = in.next();
        if(position.equals("a8") || position.equals("h8") || position.equals("a1") || position.equals("h1")){
            out.printLine(3);
        } else if(position.startsWith("a") || position.startsWith("h") || position.endsWith("8") || position.endsWith("1")) {
            out.printLine(5);
        } else {
            out.printLine(8);
        }
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if ( line == null ) {
                    return false;
                }
                tokenizer = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() { return Double.parseDouble(next());}
}
class OutputWriter {
    private final PrintWriter writer;
    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }
    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }
    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if ( i != 0 ) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }
    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }
    public void close() {
        writer.close();
    }
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if ((s.contains("h") || s.contains("a"))&&(s.contains("1") || s.contains("8"))) {

                System.out.println("3");
            } else if (s.contains("1") || s.contains("8") || s.contains("h") || s.contains("a")) {
                System.out.println("5");
            } else {
                System.out.println("8");
            }
        }

    }

import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class FirstProject {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int c=0;
        if(s.charAt(0)=='a' || s.charAt(0)=='h')
        {
            if(s.charAt(1)=='1' || s.charAt(1)=='8')
                c+=3;
            else if(s.charAt(1)=='1' || s.charAt(1)=='2' || s.charAt(1)=='3' ||s.charAt(1)=='4'||s.charAt(1)=='5'||s.charAt(1)=='6'||s.charAt(1)=='7')c+=5;
        }

        else if((s.charAt(0)=='b') || (s.charAt(0)=='c') || (s.charAt(0)=='d') || (s.charAt(0)=='e') || (s.charAt(0)=='f') || (s.charAt(0)=='g'))
        {
            if(s.charAt(1)=='1' || s.charAt(1)=='8')c+=5;
            else if(s.charAt(1)=='1' || s.charAt(1)=='2' || s.charAt(1)=='3' ||s.charAt(1)=='4'||s.charAt(1)=='5'||s.charAt(1)=='6'||s.charAt(1)=='7')c+=8;
        }

        System.out.println(c);

    }
}

import java.util.*;
public class sfirst{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String arip = "abcdefgh";
		String s = scn.nextLine();
		int a = arip.indexOf(s.split("")[0])+1;
		int b = Integer.parseInt(s.split("")[1]);
		if(b > a){
			int h = a;
			a = b;
			b = h;
		}
		if ((a == 1 && b ==1) || (a == 8 && b ==8) || (a == 1 && b == 8) || (a == 8 && b == 1)) {
			System.out.println(3);
		}
		else if((a == 1 || b ==1) || (a == 8 || b ==8) ||  (a == 1 || b == 8) || (a == 8 || b == 1)){
			System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

import java.util.Scanner;

public class KingMovesTamadVersion{
	public static void main (String[] args){
	        Scanner kbd = new Scanner (System.in);
	        String input = kbd.nextLine();
	        char c = input.charAt(0);
	        int x = 0;
	        String r = input.charAt(1) + "";
	        int y = Integer.parseInt(r) + 0;

	        switch (c) {
	            case 'a': x = 1;break;
	            case 'b': x = 2;break;
	            case 'c': x = 3;break;
	            case 'd': x = 4;break;
	            case 'e': x = 5;break;
	            case 'f': x = 6;break;
	            case 'g': x = 7;break;
	            case 'h': x = 8;break;
	        }

	        if(x == 1 && y == 1 || x == 1 && y == 8 || x == 8 && y == 1 || x == 8 && y == 8 ){
	        	System.out.print("3");
	        }
	        else if ( ((x > 1  && y < 2) && (x < 8 && y <2)) || ((x > 1  && y == 8) && (x < 8 && y == 8))  || ((x == 1 && y > 1 ) && (x == 1 && y < 8)) || ((x == 8 && y > 1 ) && (x == 8 && y < 8)) ){
	        	System.out.print("5");
	        }
	        else{
	        	System.out.print("8");
	        }
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Solution solution = new Solution();
    solution.solve(in, out);
    out.close();
  }

  private static class Solution {
    final int[][] moves = {
        {1, -1},
        {1, 0},
        {1, 1},
        {0, -1},
        {0, 1},
        {-1, -1},
        {-1, 0},
        {-1, 1}
    };

    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      int count = 0;
      char r = cell.charAt(1);
      char c = cell.charAt(0);
      for (int[] move : moves) {
        char newRow = (char) (r + move[0]);
        char newCol = (char) (c + move[1]);
        count += isValidCell(newRow, newCol) ? 1 : 0;
      }
      out.println(count);
    }

    boolean isValidCell(char r, char c) {
      return r >= '1' && r <= '8' && c >= 'a' && c <= 'h';
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.util.*;
import java.lang.*;

public class Program{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String inp = sc.nextLine();
        if(inp.equals("a8") || inp.equals("a1") || inp.equals("h1") || inp.equals("h8")) {
            System.out.println("3");
            return;
        }

        if(inp.charAt(0)=='a' || inp.charAt(0)=='h' || inp.charAt(1)=='1' || inp.charAt(1)=='8'){
            System.out.println("5");
            return;
        }

        System.out.println("8");
    }
}

import java.util.Scanner;

public class W {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String cd = in.next();
		char c = cd.charAt(0);
		char d = cd.charAt(1);
//		int q = 4;
//		int r = 3;
//		int z = 2;
//		if (("bcdefg".indexOf(c) >= 0) && ("234567".indexOf(d) >= 0)) {
//			System.out.println(q);
//		}
//		if (("bcdefg".indexOf(c) >= 0) && ("18".indexOf(d) >= 0)) {
//			System.out.println(r);
//		}
//		if (("ah".indexOf(c) >= 0) && ("234567".indexOf(d) >= 0)) {
//			System.out.println(r);
//		}
//		if (("ah".indexOf(c) >= 0) && ("18".indexOf(d) >= 0)) {
//			System.out.println(z);
//		}

		int x = c - 'a';
		int y = d - '1';

		int answer = 0;
		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				if (dx == 0 && dy == 0) continue;

				int xx = x + dx, yy = y + dy;
				if (xx < 0 || 8 <= xx) continue;
				if (yy < 0 || 8 <= yy) continue;

				++answer;
			}
		}

		System.out.println(answer);
	}

}

//package leto;

import java.io.FileNotFoundException;
import java.util.Scanner;

public class forc_368C {
	public static void main(String[] args) throws FileNotFoundException {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		if(s.charAt(0) == 'a'){
			if((s.charAt(1) == '1')||(s.charAt(1) == '8')){
				System.out.println(3);
			} else {
				System.out.println(5);
			}
		}
		if(s.charAt(0) == 'h'){
			if((s.charAt(1) == '1')||(s.charAt(1) == '8')){
				System.out.println(3);
			} else {
				System.out.println(5);
			}
		}
		if((s.charAt(1) == '1')&&(s.charAt(0) != 'a')&&(s.charAt(0) != 'h')){
			System.out.println(5);
		}
		if((s.charAt(1) == '8')&&(s.charAt(0) != 'a')&&(s.charAt(0) != 'h')){
				System.out.println(5);
		}
		if((s.charAt(0) != 'a')&&(s.charAt(0) != 'h')&&(s.charAt(1) != '1')&&(s.charAt(1) != '8')){
			System.out.println(8);
		}
		scan.close();
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    (new Solution()).solve(new InputReader(System.in), new PrintWriter(System.out));
  }

  private static class Solution {
    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      char row = cell.charAt(1);
      char col = cell.charAt(0);
      int type = 0;
      if (col == 'a' || col == 'h') {
        type++;
      }
      if (row == '1' || row == '8') {
        type++;
      }
      if (type == 0) {
        out.println(8);
      } else if (type == 1) {
        out.println(5);
      } else {
        out.println(3);
      }
      out.close();
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String args[])throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        int r = s.charAt(0) - 'a';
        int c = Integer.parseInt(Character.toString(s.charAt(1))) - 1;
        if (r > 0 && r < 7 && c > 0 && c < 7)
            System.out.println(8);
        else
        {
            if ((r == 0 || r == 7) && (c == 0 || c == 7))
                System.out.println(3);
            else
                System.out.println(5);
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}

import java.util.*;

public class ProblemSolving {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int x = s.charAt(1) - 48;
        int y = s.charAt(0) - 96;
        if((x == 1 && y == 1) || (x == 8 && y == 8))
            System.out.println("3");
        else if((int)Math.abs(x - y) == 7)
            System.out.println("3");
        else if (x == 1 || x == 8 || y == 1 || y == 8)
            System.out.println("5");
        else
            System.out.println("8");

    }

}

import java.util.*;

public class saf {

    public static void main(String[] args) {

    	Scanner sc = new Scanner (System.in);
        String s =sc.next();
        char y =s.charAt(0);
        char z=s.charAt(1);
        int x=0;
        switch(y){
        	case 'b':
        	case 'c':
        	case 'd':
        	case 'e':
        	case 'f':
        	case 'g':x=(z=='8' || z=='1')? 5 : 8 ; break;
        	case 'h':x=(z=='8' || z=='1')? 3 : 5 ; break;

        	case 'a':x=(z=='8' || z=='1')? 3 : 5 ; break;
        }
        System.out.println(x);
    }}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in=new Scanner(System.in);
        String a=in.next();
        String c=a.substring(0, 1);
        String r=a.substring(1, 2);

        int b;
        if((c.equals("h")&&(r.equals("8")||r.equals("1")))||(c.equals("a")&&(r.equals("8")||r.equals("1"))))b=3;
        else if (c.equals("h")||r.equals("8")||r.equals("1")||c.equals("a") )b=5;
        else b=8;
        System.out.println(b);

    }
}

import java.util.Scanner;

public class A {
      public static void main(String[]args){
    	  Scanner sc=new Scanner(System.in);
    	  String temp=sc.nextLine();
    	  int p1=temp.charAt(0)-'a'+1;
    	  int p2=temp.charAt(1)-'0';
    	  int ans=8;
    	  if(p1==1||p1==8)ans-=3;
    	  if(p2==1||p2==8)ans-=3;
    	  if(ans==2)ans++;
    	  System.out.println(ans);
      }
}

import java.util.Scanner;
public class chess{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		   String s=sc.nextLine();
            if((s.charAt(0)=='a'||s.charAt(0)=='h')&&(s.charAt(1)=='8'||s.charAt(1)=='1'))
            {

            	System.out.println(3);

            }
            else if(s.charAt(0)=='a'||s.charAt(0)=='h'||s.charAt(1)=='8'||s.charAt(1)=='1')
            	System.out.println(5);
            else
            	System.out.println(8);
	}
}

/**
 *
 *
 *
 * @author
 * @version 1.00 2016/10/23
 */

import java.util.*;

public class KingMoves{
	public static void main (String args []){

		Scanner kbd = new Scanner(System.in);
		String s = kbd.nextLine();
		char c = s.charAt(0);
		char r = s.charAt(1);
		int o = 0;

		if (c == 'a' || c == 'h'){
			if (r == '1' || r == '8'){
				o = 3;
			} else{
				o = 5;
			  }

		}else if (r == '1' || r == '8'){
			o = 5;
		} else{
			o = 8;
		}
		System.out.print(o);
	}
}

import java.util.Scanner;

public class Tester {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			String s;
			Scanner sc = new Scanner(System.in);
			s = sc.nextLine();
				if(s.charAt(1)-49==0|| s.charAt(1)-56==0 || s.charAt(0)=='a' || s.charAt(0) == 'h')
						{
								if((s.charAt(0)=='a' || s.charAt(0) == 'h')&&(s.charAt(1)-49==0|| s.charAt(1)-56==0))
								System.out.println(3);
								else
									System.out.println(5);
						}

			else
				System.out.println(8);
	}

}

import java.util.Scanner;
import java.util.Arrays;
import java.lang.*;
public class mitul
{
       public static void main(String args[])
       {

            Scanner scan = new Scanner(System.in);
            String str = scan.nextLine();
            if(str.charAt(0)=='a'|| str.charAt(0)=='h')
            {
                   if(str.charAt(1)=='1' || str.charAt(1)=='8')
                   {
                          System.out.println("3");
                   }
                   else
                   {
                          System.out.println("5");
                   }
            }
            if(str.charAt(1)=='1' || str.charAt(1)=='8')
            {
                   if(str.charAt(0)!='a' && str.charAt(0)!='h')
                   {
                          System.out.println("5");
                   }
            }
            if(str.charAt(1)!='1' && str.charAt(1)!='8')
            {
                   if(str.charAt(0)!='a' && str.charAt(0)!='h')
                   {
                          System.out.println("8");
                   }
            }
       }
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputStream inputstream = System.in;
		OutputStream outputstream = System.out;
		InputReader in = new InputReader(inputstream);
		PrintWriter out = new PrintWriter(outputstream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testN, InputReader in, PrintWriter out) {
			String str = in.next();
			boolean p = str.charAt(0) == 'a';
			boolean q = str.charAt(0) == 'h';
			boolean r = str.charAt(1) == '1';
			boolean s = str.charAt(1) == '8';
			if (p || q) {
				if (r || s) {
					out.println(3);
				}
				else {
					out.println(5);
				}
			}
			else {
				if (r || s) {
					out.println(5);
				}
				else {
					out.println(8);
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		/*
		public long nextLong() {
			return Long.parseLong(next());
		}
		*/
		public int nextInt() {
			return Integer.parseInt(next());
		}
		/*
		public short nextShort() {
			return Short.parseShort(next());
		}

		public byte nextByte() {
			return Byte.parseByte(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public boolean hasNext() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) {
						return false;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return true;
		}
		*/
	}
}

import java.util.*;

public class Main {
  public static void main(String[] args) {
  	Scanner sc=new Scanner(System.in);
  	String point = sc.next();
  	char letter = point.charAt(0);
  	char number = point.charAt(1);
  	int res = 0;
  	String ltest = "bcdefg";
  	String ntest = "234567";
  	if ((letter == 'a' && (number == '1' || number == '8')) || (letter == 'h' &&(number== '1' || number == '8'))) res = 3;
  	else{
  		if (letter == 'a' || letter == 'h'){
  			String number1 = Character.toString(number);
  			if (ntest.contains(number1)) res = 5;
  		}
  		else{
  			if (number == '1' || number == '8'){
  				String letter1 = Character.toString(letter);
  				if (ltest.contains(letter1)) res = 5;
  			}
  			else res = 8;
  		}
  	}
    System.out.println(res);
  }

}

import java.util.Scanner;
public class KingMoves {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String c=s.next();
		int output;
		switch(c.charAt(0)){
		case 'a':
		case 'h':output=(Character.getNumericValue(c.charAt(1))==8||Character.getNumericValue(c.charAt(1))==1)? 3:5;break;
		case 'b':
		case 'c':
		case 'd':
		case 'e':
		case 'f':
		case 'g':output=(Character.getNumericValue(c.charAt(1))==8||Character.getNumericValue(c.charAt(1))==1)? 5:8;break;
		default: output=8;
		}
		System.out.println(output);
	}

}

import java.io.*;
import java.util.*;

public class KingMoves
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

		String pos = st.nextToken();

		char column = pos.charAt(0);
		int columnindex = (int) column-96;
		int rowindex = Character.getNumericValue(pos.charAt(1));

		if(rowindex>1 && rowindex<8 && columnindex>1 && columnindex<8)
		      System.out.println(8);
		else if((rowindex==8 || rowindex==1) && columnindex>1 && columnindex<8)
		      System.out.println(5);
	      else if(rowindex>1 && rowindex<8 && (columnindex==1 || columnindex==8))
		      System.out.println(5);
	      else
	            System.out.println(3);

	}
}

 import java.util.*;
public class king
{
public static void main(String args[])
{
Scanner input =new Scanner(System.in);
System.out.print(" ");
String s=input.nextLine();
int m;
if(s.charAt(0)==97 || s.charAt(0)==104)
{
if(s.charAt(1)==49 || s.charAt(1)==56)
m=3;
else
m=5;
}
else if(s.charAt(1)==49 || s.charAt(1)==56)
m=5;
else
m=8;
System.out.println(m);
}
}

import java.io.IOException;
import static java.lang.Math.*;
import java.math.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        if(s.equals("a1")||s.equals("h1")||s.equals("h8")||s.equals("a8"))
            System.out.println(3);
        else if(s.charAt(0)=='a'||s.charAt(0)=='h'||s.charAt(1)=='1'||s.charAt(1)=='8')
            System.out.println(5);
        else
            System.out.println(8);
    }

    static int prime(int p) {
        int t = (int) sqrt(Integer.parseInt(p + ""));
        if (t <= 1) {
            return 0;
        }
        for (long i = 2; i <= t; i++) {
            if (p % i == 0) {
                return 0;
            }

        }
        return 1;
    }

    static int Obe(long a, long b) {
        BigInteger b1 = new BigInteger("" + a);
        BigInteger b2 = new BigInteger("" + b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    static int che(int[] w) {
        Set<Integer> list = new LinkedHashSet<>();
        for (int i = 0; i < w.length; i++) {
            list.add(w[i]);
        }
        return list.size();
    }

    private static ArrayList<BigInteger> fibCache = new ArrayList<BigInteger>();

    static {
        fibCache.add(BigInteger.ZERO);
        fibCache.add(BigInteger.ONE);
    }

    public static BigInteger fib(int n) {
        if (n >= fibCache.size()) {
            fibCache.add(n, fib(n - 1).add(fib(n - 2)));
        }

        return fibCache.get(n);
    }

}

import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner var=new Scanner(System.in);
        String s=var.next();
        int d=(int)s.charAt(1)-48;
        int c=(int)s.charAt(0)-96;
        int g=0;
        if((c-1>0)&&(d-1>0))
            g++;
        if((c-1>0)&&(d>0))
            g++;
        if((c-1>0)&&(d+1<9))
            g++;
        if((c>0)&&(d+1<9))
            g++;
        if((c+1<9)&&(d+1<9))
            g++;
        if((c+1<9)&&(d>0))
            g++;
        if((c+1<9)&&(d-1>0))
            g++;
        if((c>0)&&(d-1>0))
            g++;
        System.out.println(g);
    }
}

import java.util.Scanner;

/**
 *
 * @author toshiba
 */
public class Tests {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
         if((str.charAt(0) == 'a' && str.charAt(1) == '1')
                 || (str.charAt(0) == 'a' && str.charAt(1) == '8')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '1')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '8'))
            System.out.println(3);
         else if(
                 ((str.charAt(0) == 'a' || str.charAt(0) == 'h')
                 && (str.charAt(1) >= 49 || str.charAt(1) <= 56)))
                 System.out.println(5);
         else if (((str.charAt(0) >= 'a' || str.charAt(0) <= 'h')
                 && (str.charAt(1) == 49 || str.charAt(1) == 56)))
             System.out.println(5);
         else
             System.out.println(8);
        }
    }

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    PrintWriter out = new PrintWriter(System.out);
    (new Solution()).solve(new InputReader(System.in), out);
    out.close();
  }

  private static class Solution {
    final int[][] moves = {
        {1, -1},
        {1, 0},
        {1, 1},
        {0, -1},
        {0, 1},
        {-1, -1},
        {-1, 0},
        {-1, 1}
    };

    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      int numOfMoves = 0;
      char row = cell.charAt(1);
      char col = cell.charAt(0);
      for (int[] move : moves) {
        char moveRow = (char) (row + move[0]);
        char moveCol = (char) (col + move[1]);
        numOfMoves += isValidCell(moveRow, moveCol) ? 1 : 0;
      }
      out.println(numOfMoves);
    }

    boolean isValidCell(char row, char col) {
      return row >= '1' && row <= '8' && col >= 'a' && col <= 'h';
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.io.*;
import java.util.*;
import java.util.TreeSet;
import java.lang.*;
import java.text.DecimalFormat;
public class ab{
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		String z=in.next();
		char c=z.charAt(0),r=z.charAt(1);
		if(c=='a'||c=='h'){
			if(r=='1'||r=='8')
				System.out.println(3);
			else
				System.out.println(5);
		}
		else if(r=='1'||r=='8'){
			System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

import java.util.Scanner;

/**
 * Created by Женя on 29.01.2017.
 */
public class Task_710A {
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();

        if ((a.contains("a") || a.contains("h")) && (a.contains("1") || a.contains("8"))) {
            System.out.print(3);
        }
        else if (a.contains("a") || a.contains("h"))System.out.print(5);

        else if (a.contains("1") || a.contains("8")){
            System.out.print(5);
        }
        else if (!(a.contains("a") || a.contains("h")|| a.contains("1") || a.contains("8"))){
            System.out.print(8);
        }
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		String in=st.nextToken();
		char ina[]=new char[2];
		ina[0]=in.charAt(0);
		ina[1]=in.charAt(1);

		if(ina[0]!='a'&&ina[0]!='h'){
			if(ina[1]!='1'&&ina[1]!='8'){
				System.out.println(8);
			}
			else{
				System.out.println(5);
			}
		}
		else{
			if(ina[1]!='1'&&ina[1]!='8'){
				System.out.println(5);
			}
			else{
				System.out.println(3);
			}
		}
	}
}

import java.util.Scanner;

public class A {
      public static void main(String[]args){
    	  Scanner sc=new Scanner(System.in);
    	  String temp=sc.nextLine();
    	  int p1=temp.charAt(0)-'a'+1;
    	  int p2=temp.charAt(1)-'0';
    	  int ans=8;
    	  if(p1==1||p1==8)ans-=3;
    	  if(p2==1||p2==8)ans-=3;
    	  if(ans==2)ans++;
    	  System.out.println(ans);
      }
}

import java.util.*;
public class sfirst{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String arip = "abcdefgh";
		String s = scn.nextLine();
		int a = arip.indexOf(s.split("")[0])+1;
		int b = Integer.parseInt(s.split("")[1]);
		if ((a == 1 && b ==1) || (a == 8 && b ==8) || (a == 1 && b == 8) || (a == 8 && b == 1)) {
			System.out.println(3);
		}
		else if((a == 1 || b ==1) || (a == 8 || b ==8) ||  (a == 1 || b == 8) || (a == 8 || b == 1)){
			System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

import java.util.Scanner;

/**
 * Created by LevDavid on 8/22/2016.
 */
public class HelloWorld {

    public static void main(String[] args) {
        // write your code here
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        if (input.charAt(0) < 'h' && input.charAt(0) > 'a') {
            if (input.charAt(1) == '1' || input.charAt(1) == '8') {
                System.out.println(5);
            } else {
                System.out.println(8);
            }
        } else {
            if (input.charAt(1) == '1' || input.charAt(1) == '8') {
                System.out.println(3);
            } else {
                System.out.println(5);
            }
        }
    }
}

/**
 *
 *
 *
 * @author
 * @version 1.00 2016/10/23
 */

import java.util.*;

public class KingMoves{
	public static void main (String args []){

		Scanner kbd = new Scanner(System.in);
		String s = kbd.nextLine();
		char c = s.charAt(0);
		char r = s.charAt(1);
		int o = 0;

		if (c == 'a' || c == 'h'){
			if (r == '1' || r == '8'){
				o = 3;
			} else{
				o = 5;
			  }

		}else if (r == '1' || r == '8'){
			o = 5;
		} else{
			o = 8;
		}
		System.out.print(o);
	}
}

import java.util.Scanner;

public class KingMoves{
	public static void main(String[] args){
		Scanner keyboard = new Scanner(System.in);
		String position = keyboard.nextLine();

		char d = position.charAt(0);
		char c = position.charAt(1);

		int moves = 0;

		if ( position.equals("a8") ||
			 position.equals("a1") ||
			 position.equals("h8") ||
			 position.equals("h1") )
			moves = 3;

		else if (d == 'a' || d == 'h' ||
				 c == '1' || c == '8')
			moves=5;
		else
			moves=8;

		System.out.println(moves+"");

	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in=new Scanner(System.in);
        String x=in.next();
        char []a=x.toCharArray();
        int b;
        if(a[0]=='a'||a[0]=='h')
        {
            if(a[1]=='1'||a[1]=='8')b=3;
            else b=5;
        }
        else if(a[1]=='1'||a[1]=='8')b=5;
        else b=8;
        System.out.println(b);
    }
}

import java.util.Scanner;

public class KingMoves{
  public static void main(String[] args){
  Scanner s=new Scanner(System.in);
  while (s.hasNextLine()){
    String m=s.nextLine();
    System.out.println(input(m));
    }
  s.close();
  }

  public static int input(String pos) {
    int col= pos.charAt(0)+1-'a';
    int row= pos.charAt(1)-'0';
    boolean cc= (col>=2 && col<=7);
    boolean rr= (row>=2 && row<=  7);
    return cc ? (rr? 8: 5) : (rr? 5:3);
  }
}

import java.util.*;

public class KingMoves {
	public static void main(String[] agrs) {
		Scanner input = new Scanner(System.in);
		String s;

		s = input.nextLine();

		String column = s.substring(0, 1);
		String row = s.substring(1,2);

		if (column.equals( "a") || column.equals("h")) {
			if (row.equals("1") || row.equals( "8")) {
			System.out.println(3);
			}
			else {
			System.out.print(5);
			}
		}
		else {
			if (row.equals("1") || row.equals("8")) {
				System.out.println(5);
			}
			else {
			System.out.println(8);
			}
		}
	}
}

import java.util.*;

public class A710 {
    public static boolean isEdge(int x) {
        return x == 1 || x == 8;
    }

    public static boolean isCorner(int x, int y) {
        return isEdge(x) && isEdge(y);
    }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String str = scan.next();

		int a = (int)(str.charAt(0) - 'a') + 1;
		int b = Integer.valueOf(str.substring(1,2));

// 		System.out.println(a);
// 		System.out.println(b);

		int ans = 8;
		if (isCorner(a, b)) {
		    ans = 3;
		}
		else if (isEdge(a) || isEdge(b)) {
		    ans = 5;
		}

		System.out.print(ans);
	}
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputStream inputstream = System.in;
		OutputStream outputstream = System.out;
		InputReader in = new InputReader(inputstream);
		PrintWriter out = new PrintWriter(outputstream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testN, InputReader in, PrintWriter out) {
			String str = in.next();
			boolean p = str.charAt(0) == 'a';
			boolean q = str.charAt(0) == 'h';
			boolean r = str.charAt(1) == '1';
			boolean s = str.charAt(1) == '8';
			if (p || q) {
				if (r || s) {
					out.println(3);
				}
				else {
					out.println(5);
				}
			}
			else {
				if (r || s) {
					out.println(5);
				}
				else {
					out.println(8);
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputStream inputstream = System.in;
		OutputStream outputstream = System.out;
		InputReader in = new InputReader(inputstream);
		PrintWriter out = new PrintWriter(outputstream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testN, InputReader in, PrintWriter out) {
			String s = in.next();
			char a = s.charAt(0);
			char b = s.charAt(1);
			if (a == 'a' || a == 'h') {
				if (b == '1' || b == '8') {
					out.println(3);
				}
				else {
					out.println(5);
				}
			}
			else {
				if (b == '1' || b == '8') {
					out.println(5);
				}
				else {
					out.println(8);
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public short nextShort() {
			return Short.parseShort(next());
		}

		public byte nextByte() {
			return Byte.parseByte(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public boolean hasNext() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) {
						return false;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return true;
		}
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Solution solution = new Solution();
    solution.solve(in, out);
    out.close();
  }

  private static class Solution {
    final int[][] moves = {
        {1, -1},
        {1, 0},
        {1, 1},
        {0, -1},
        {0, 1},
        {-1, -1},
        {-1, 0},
        {-1, 1}
    };

    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      int numOfMoves = 0;
      char row = cell.charAt(1);
      char col = cell.charAt(0);
      for (int[] move : moves) {
        char moveRow = (char) (row + move[0]);
        char moveCol = (char) (col + move[1]);
        numOfMoves += isValidCell(moveRow, moveCol) ? 1 : 0;
      }
      out.println(numOfMoves);
    }

    boolean isValidCell(char row, char col) {
      return row >= '1' && row <= '8' && col >= 'a' && col <= 'h';
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.io.*;
import java.util.StringTokenizer;

public class Codeforces {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Solution solution = new Solution();
    solution.solve(in, out);
    out.close();
  }

  private static class Solution {
    final int[][] moves = {
        {1, -1},
        {1, 0},
        {1, 1},
        {0, -1},
        {0, 1},
        {-1, -1},
        {-1, 0},
        {-1, 1}
    };

    void solve(InputReader in, PrintWriter out) {
      String cell = in.nextLine();
      int count = 0;
      char r = cell.charAt(1);
      char c = cell.charAt(0);
      for (int[] move : moves) {
        char rowMove = (char) (r + move[0]);
        char colMove = (char) (c + move[1]);
        count += isValidCell(rowMove, colMove) ? 1 : 0;
      }
      out.println(count);
    }

    boolean isValidCell(char r, char c) {
      return r >= '1' && r <= '8' && c >= 'a' && c <= 'h';
    }
  }

  private static class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreElements()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = null;
      try {
        str = reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return str;
    }
  }
}

import java.util.*;
public class King
{

    public static void main(String[] args)
    {
       Scanner sc=new Scanner(System.in);
       String pos=sc.next();
       if(pos.charAt(0)=='a'||pos.charAt(0)=='h')
       {
          if(pos.charAt(1)=='8'||pos.charAt(1)=='1')
              System.out.println(3);
          else
              System.out.println(5);
       }
       else if(pos.charAt(1)=='8'||pos.charAt(1)=='1')
       {
           if(pos.charAt(0)=='a'||pos.charAt(0)=='h')
              System.out.println(3);
          else
              System.out.println(5);
       }
       else
           System.out.println(8);
    }

}

import java.io.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.*;

public class Main
{

 static  int t,n,i,q,w,c,x,ans,z;
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    public static void main(String[] args) throws Exception
    {
   int n,q,i,ans=0;
        String ss1;
        Reader s=new Reader();
      ss1=s.readLine();
        char c=ss1.charAt(0);
        char d=ss1.charAt(1);
        if(c=='a'||c=='h')
            {
            if((d=='1'))
                ans=3;
            else if(d=='8')
                ans=3;

                else ans=5;
        }
        else if(c!='a'&&c!='h')
        {if((d=='1')||(d=='8'))
            ans=5;

        else ans=8;
        }
System.out.println(ans);
    }

 }

import java.util.*;

public class bucky{

public static void main (String args[]) {

Scanner input=new Scanner(System.in);

HashMap<Integer, Integer> map= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> map1= new HashMap<Integer, Integer>();

		String str=input.nextLine();

		if(str.equals("a1") || str.equals("a8")||
		str.equals("h1")|| str.equals("h8")  ) System.out.println(3);

		else if(str.substring(0,1).equals("a") ||
		str.substring(0,1).equals("h") || str.substring(1).equals("1") ||

		str.substring(1).equals("8"))

		 System.out.println(5);

		else System.out.println(8);

		}

		}

import java.util.Scanner;

public class King {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        String [] a = input.split("");
        int number = Integer.parseInt(a[1]);
        int matrix [][] = {{3,5,5,5,5,5,5,3},
                           {5,1,1,1,1,1,1,1},
                           {5,1,1,1,1,1,1,1},
                           {5,1,1,1,1,1,1,1},
                           {5,1,1,1,1,1,1,1},
                           {5,1,1,1,1,1,1,1},
                           {5,1,1,1,1,1,1,1},
                           {3,5,5,5,5,5,5,3}};
        char letter = a[0].charAt(0);
        if(letter =='a' &&( number == 1 || number == 8)){
            System.out.print(3);
        }
        else if (letter == 'h' &&( number ==1 || number == 8)){
            System.out.print(3);
        }
        else if((letter!= 'a' && letter!='h')&& ( number ==1 || number ==8)){
            System.out.print(5);

        }
        else if((number!=7 && number !=1) && (letter=='a' || letter=='h')){
            System.out.print(5);
        }
        else{
            System.out.print(8);
        }

    }
}

import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		String str = in.next();

		int x = str.charAt(0) - 'a';
		int y = str.charAt(1) - '1';

		int ans = -1;
		for(int i = x-1; i <= x+1; i++)
			for(int j = y-1; j <= y+1; j++)
				if(i >= 0 && i < 8 && j >= 0 && j < 8)
					ans++;

		System.out.println(ans);

		in.close();
	}
}

    import java.util.*;
    import java.lang.*;
    import java.io.*;

    public class S{
        public static void main(String[] args) {
		String s1;
		Scanner sc = new Scanner(System.in);
		String position = sc.nextLine();
		System.out.println(kingMoves(position));
	}

	public static int kingMoves(String position) {
		int x = Character.getNumericValue(position.charAt(0));
		int y = Character.getNumericValue(position.charAt(1));

		int moves =0;
		if( (x==10 || x==17) && (y==1 || y==8)) {
			moves+=3;
		}else if( (x>10 && x<17 && y==1) || (x>10 && x<17 && y==8) || (y>1 && y<8 && x==10) || (y>1 && y<8 && x==17)) {
			moves+=5;
		}else if(x>10 && x<17 && y>1 && y<8){
			moves+=8;
		}

		return moves;
	}
    }

import java.math.*;
import java.text.*;

import java.util.*;

public class CompleteSearch {
 public static Scanner in =new Scanner(System.in);

    public static long getDist(int val,LinkedList<Integer>list){
        long ans=0;
        for(int cur:list)
            ans+=(Math.abs(val-cur));
        return ans;
    }
    public static void main(String[] args){
         String txt=in.next().toLowerCase();
        char c=txt.charAt(0);
        int r=Integer.valueOf(txt.charAt(1)+"");
        if(c=='a'||c=='h'){
            if(r==1||r==8)
                System.out.println("3");
            else
                System.out.println("5");
        }
        else if(r==8||r==1){
            if(c=='a'||c=='h')
                System.out.println("3");
            else
                System.out.println("5");
        }
        else
            System.out.println("8");
    }

}

import java.util.*;

public class saf {

    public static void main(String[] args) {

    	Scanner sc = new Scanner (System.in);
        String s =sc.next();
        char y =s.charAt(0);
        char z=s.charAt(1);
        int x=0;
        switch(y){
        	case 'b':
        	case 'c':
        	case 'd':
        	case 'e':
        	case 'f':
        	case 'g':x=(z=='8' || z=='1')? 5 : 8 ; break;
        	case 'h':x=(z=='8' || z=='1')? 3 : 5 ; break;

        	case 'a':x=(z=='8' || z=='1')? 3 : 5 ; break;
        }
        System.out.println(x);
    }}

//package EducationalRound16;

import java.util.Scanner;

/**
 * Created by legonaftik on 8/22/16.
 */
public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String position = sc.next();
        char horizontal = position.charAt(0);
        char vertical = position.charAt(1);

        if ( (horizontal=='a' || horizontal=='h') && (vertical=='1' || vertical=='8') ) {
            System.out.println(3);
        } else if ( horizontal=='a' || horizontal=='h' || vertical=='1' || vertical=='8' ) {
            System.out.println(5);
        } else {
            System.out.println(8);
        }
    }
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author asus
 */
public class hodikorolya {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String c = in.nextLine();
        String[] s = c.split("");
        String f = s[0];
        int g = Integer.parseInt(s[1]);
        int cde = 0;
        if ((f.equals("a")||f.equals("h")) && ((g == 1 || g == 8))) {
            cde=3;
        }
        if((f.equals("a")||f.equals("h"))&&((g != 1 || g != 8))){
            cde=5;
        }
        if(!f.equals("h")&&!f.equals("a")&& g!=1 && g!=8){
            cde=8;
        }
        System.out.println(cde);

    }
}

//import java.io.FileWriter;
import java.util.*;
import java.io.*;
//import java.util.*;
public class p1 {
    public static void main(String[] args) throws IOException {
//        Scanner in = new Scanner(new FileReader("input.txt"));
        Scanner sc = new Scanner(System.in);
//        PrintWriter out = new PrintWriter("output.txt");
        //*----------------------------------------------------------
        String a = sc.next();
        if (a.substring(1).equals("8") || a.substring(1).equals("1"))
            if (a.substring(0, 1).equals("a") || a.substring(0, 1).equals("h")){
                System.out.println(3);
                return;
            }
        if (!a.substring(0, 1).equals("a") || !a.substring(0, 1).equals("h")){
            System.out.println(5);
            return;
        }
        System.out.println(8);
        //*----------------------------------------------------------
//        out.println();
//        in.close();
//        out.close();
        sc.close();
    }
}

import java.util.Scanner;
public class KingMoves {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String c=s.next();
		int output;
		switch(c.charAt(0)){
		case 'a':
		case 'h':output=(Character.getNumericValue(c.charAt(1))==8||Character.getNumericValue(c.charAt(1))==1)? 3:5;break;
		default: output=8;
		}
		System.out.println(output);
	}

}

import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String position = in.next();
            char col = position.charAt(0);
            int row = Integer.valueOf(String.valueOf(position.charAt(1)));
            int result = 8;
            boolean inEdge = false;
            if (row == 1 || row == 8) {
                result -= 3;
                inEdge = true;
            }
            if (col == 'a' || row == 'h') {
                result -= 3;
                if (inEdge) result = 3;
            }
            System.out.println(result);
        }
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class C{
	public static void main( String[] args ){
		Scanner scanner = new Scanner( System.in );
		char[] loc = scanner.next( ).toCharArray();
		int a = 8;
		if(loc[1]=='1' || loc[1]=='8') a-=3;
		if(loc[0]=='h' || loc[0]=='a') a-=3;
		if((loc[1]=='1' || loc[1]=='9')&&(loc[0]=='h' || loc[0]=='a')) ++a;
		System.out.println( a );
	}
}

import java.util.*;
public class eduRound {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		char row = input.charAt(0);
		int col = input.charAt(1)-'0';
		int sides = 0;
		if (row=='a' || row=='h') {
			sides++;
		}
		if (col==0 || col==8) {
			sides++;
		}
		switch (sides) {
		case 0:
			System.out.println(8);
			break;
		case 1:
			System.out.println(5);
			break;
		case 2:
			System.out.println(3);
			break;
		}
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
//        TaskA solver = new TaskA();
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] c = in.next().toCharArray();
//        int[][]arr=new int [8][8];
//            System.out.println('e'-'a');
            int row = c[0] - 'a' + 1;
//            System.out.println(row);
            int column = c[1] - '1';
//            System.out.println(isrowvalid(row));

            if (iscolumnvalid(column) && isrowvalid(row)) {
                System.out.println("8");
                return;
            }

            if (!isrowvalid(row) && !iscolumnvalid(column)) {
                System.out.println("3");
                return;

            }
            if (!isrowvalid(row) || !iscolumnvalid(column)) {
                System.out.println("5");
                return;

            }
        }

        private boolean isrowvalid(int row) {
            return (row - 1 >= 1 && row + 1 <= 8);
        }

        private boolean iscolumnvalid(int column) {
//            System.out.println(column);
            return (column - 1 >= 1 && column + 1 <= 8);

        }

    }
}

import java.io.*;
import java.util.*;

public class Main {

    private static StringBuilder data = new StringBuilder();
    private final static FastReader in = new FastReader();

    public static void main(String[] args) {

      String s=in.line();
     if(s.charAt(0)>'a'&&s.charAt(0)<'h'&&s.charAt(1)>'1'&&s.charAt(1)<'8'){
         System.out.println(8);
     }else if((s.charAt(0)=='1'||s.charAt(0)=='8')&&(s.charAt(1)=='a'||s.charAt(1)=='h')){
         System.out.println(3);
     }else{
         System.out.println(5);
     }
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int inT() {
            return Integer.parseInt(next());
        }

        long lonG() {
            return Long.parseLong(next());
        }

        float floaT() {
            return Float.parseFloat(next());
        }

        double doublE() {
            return Double.parseDouble(next());
        }

        String line() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.*;

public class A710 {
    public static boolean isEdge(int x) {
        return x == 1 || x == 8;
    }

    public static boolean isCorner(int x, int y) {
        return isEdge(x) && isEdge(y);
    }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String str = scan.next();

		int a = (int)(str.charAt(0) - 'a') + 1;
		int b = str.charAt(1);

		int ans = 8;
		if (isCorner(a, b)) {
		    ans = 3;
		}
		else if (isEdge(a) || isEdge(b)) {
		    ans = 5;
		}

		System.out.print(ans);
	}
}

    import java.util.*;
    import java.lang.*;
    import java.io.*;

    public class S{
        public static void main(String[] args) {
		String s1;
		Scanner sc = new Scanner(System.in);
		String position = sc.nextLine();
		System.out.println(kingMoves(position));
	}

	public static int kingMoves(String position) {
		int x = Character.getNumericValue(position.charAt(0));
		int y = Character.getNumericValue(position.charAt(1));

		int moves =0;

		System.out.println(x+" and "+y);

		if( (x==10 || x==17) && (y==1 || y==8)) {
			moves+=3;
		}else if( (x>10 && x<17 && y==1) || (x>10 && x<17 && y==8) || (y>1 && y<8 && x==10) || (y>1 && y<8 && x==17)) {
			moves+=5;
		}else if(x>10 && x<17 && y>1 && y<8){
			moves+=8;
		}

		return moves;
	}
    }

import java.util.*;

public class bucky{

public static void main (String args[]) {

Scanner input=new Scanner(System.in);

HashMap<Integer, Integer> map= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> map1= new HashMap<Integer, Integer>();

		String str=input.nextLine();

		if(str.equals("a1") || str.equals("a8")||
		str.equals("h1")|| str.equals("h8")  ) System.out.println(3);

		else if(str.substring(0,1).equals("a") ||
		str.substring(0,1).equals("h")) System.out.println(5);

		else System.out.println(8);

		}

		}

import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String args[])throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        int r = s.charAt(0) - 'a';
        int c = Integer.parseInt(Character.toString(s.charAt(1)));
        if (r > 0 && r < 7 && c > 0 && c < 7)
            System.out.println(8);
        else
        {
            if ((r == 0 || r == 7) && (c == 0 || c == 7))
                System.out.println(3);
            else
                System.out.println(5);
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}

import java.util.*;

public class Main {
  public static void main(String[] args) {
  	Scanner sc=new Scanner(System.in);
  	String point = sc.next();
  	char letter = point.charAt(0);
  	char number = point.charAt(1);
  	int res = 0;
  	String ltest = "bcdefg";
  	String ntest = "234567";
  	if ((letter == 'a' && (number == '1' || number == '8')) || (letter == 'h' &&(number== '1' || number == '8'))) res = 3;
  	else{
  		if (letter == 'a' || letter == 'h'){
  			String number1 = Character.toString(number);
  			if (ntest.contains(number1)) res = 4;
  		}
  		else{
  			if (number == '1' || number == '8'){
  				String letter1 = Character.toString(letter);
  				if (ltest.contains(letter1)) res = 4;
  			}
  			else res = 8;
  		}
  	}
    System.out.println(res);
  }

}

import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String pos = sc.next();

		String[] pos2 = pos.split("");

		if (pos2[0].equals("a") && pos2[1].equals("1")) {
			System.out.println(3);
		} else if (pos2[0].equals("a") && pos2[1].equals("8")) {
			System.out.println(3);
		} else if (pos2[0].equals("h") && pos2[1].equals("8")) {
			System.out.println(3);
		} else if (pos2[0].equals("h") && pos2[1].equals("8")) {
			System.out.println(5);
		} else if (pos2[0].equals("a")) {
			System.out.println(5);
		} else if (pos2[0].equals("h")) {
			System.out.println(5);
		} else if (pos2[1].equals("1")) {
			System.out.println(5);
		} else if (pos2[1].equals("8")) {
			System.out.println(5);
		} else {
			System.out.println(8);
		}

		sc.close();

	}

}

import java.util.Scanner;

public class Main {

    public Main() {

        Scanner kb = new Scanner(System.in);
        String input = kb.nextLine();
        int number = getNumberOfMoves(input.charAt(0),input.charAt(1));
        System.out.println(number);
        kb.close();

    }

    public static void main(String[] args) {
        new Main();
    }

    public int getNumberOfMoves(char c ,int r) {

        if (c == 'a' || c == 'h')
            if(r >1 && r <8)
                return 5;
            else
                return 3;

        if(r == 1 || r == 8)
            if (c == 'a' || c == 'h')
                return 3;
            else
                return 5;

        return 8;

    }
}

import java.util.*;
import java.util.regex.*;
import java.lang.*;

public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        char c = input.charAt(0);
        int d = input.charAt(1);

        int ans = 0;
		if (c == 'a' || c == 'h') {
			if (d == 1 || d == 8) {
				ans = 3;
			} else {
				ans = 5;
			}
		} else {
			if (d == 1 || d == 8) {
				ans = 5;
			} else {
				ans = 8;
			}
		}
		System.out.print(ans);

    }

}

import java.util.*;
public class Training{
	public static void main(String[]args){
	Scanner inp = new Scanner(System.in);
	String in = inp.next();
	char c = in.charAt(0);
	int d = in.charAt(1);
	int move;
	if(c=='a'||c=='h')
		if(d>=2||d<=7)
			move = 5;
		else
			move = 3;
	else
		move = 8;
	System.out.print(move);
	}
}

import java.util.Scanner;

public class JavaApplication57 {

    public static void main(String[] args) {
        Scanner cin=new Scanner (System.in);
        int count=0;
String s=cin.next();
char ch = s.charAt(0);
String ss= ""+s.charAt(1);
int num=Integer.parseInt(ss);
if (ch=='a' || ch=='h' || num==1 ||num==8){
if (num==1 || num==8|| num==1 ||num==8)
    count=3;
else count=5;

}
else count=8;

        System.out.println(count);

    }

}

import java.util.*;

public class A710 {
    public static boolean isEdge(int x) {
        return x == 1 || x == 8;
    }

    public static boolean isCorner(int x, int y) {
        return isEdge(x) && isEdge(y);
    }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String str = scan.next();

		int a = str.charAt(0) - 'a' + 1;
		int b = str.charAt(1);

		int ans = 8;
		if (isCorner(a, b)) {
		    ans = 3;
		}
		else if (isEdge(a) || isEdge(b)) {
		    ans = 5;
		}

		System.out.print(ans);
	}
}

import java.util.Scanner;
public class KingMoves {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String c=s.next();
		int output;
		switch(c.charAt(0)){
		case 'a':
		case 'h':output=(Character.getNumericValue(c.charAt(1))==8||Character.getNumericValue(c.charAt(1))==1)? 3:5;
		default: output=8;
		}
		System.out.println(output);
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author oleksiisosevych
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
        int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String input = in.nextLine();
            int x = input.charAt(0) - 'a';
            int y = input.charAt(1) - '0';
            int res = 0;
            for (int i = 0; i < dx.length; i++) {
                int newX = x + dx[i];
                int newY = y + dy[i];
                if (legit(newX) && legit(newY)) {
                    res++;
                }
            }
            out.println(res);
        }

        private boolean legit(int coord) {
            return coord >= 0 && coord < 8;
        }

    }
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

         Scanner sc = new Scanner(System.in);
         String s=sc.next();

         if(s.contains("h")||s.contains("a")&&s.contains("1")||s.contains("8")){
             System.out.println("3");
         }
         else if(s.contains("1")||s.contains("8")||s.contains("h")||s.contains("a")){
             System.out.println("5");
         }
         else
             System.out.println("8");

    }

}

import java.io.*;
import java.util.*;

public class KingMoves
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

		String pos = st.nextToken();

		char column = pos.charAt(0);
		int columnindex = (int) column-96;
		System.out.println(columnindex);
		int rowindex = Character.getNumericValue(pos.charAt(1));

		if(rowindex>1 && rowindex<8 && columnindex>1 && columnindex<8)
		      System.out.println(8);
		else if((rowindex==8 || rowindex==1) && (columnindex>1 || columnindex<8))
		      System.out.println(5);
	      else if((rowindex>1 || rowindex<8) && (columnindex==1 || columnindex==8))
		      System.out.println(5);
	      else
	            System.out.println(3);

	}
}

import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class FirstProject {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int c=0;
        if(s.charAt(0)=='a' || s.charAt(0)=='h')
        {
            if(s.charAt(1)=='1' || s.charAt(1)=='8')
                c+=3;
            else c+=5;
        }

        else if((s.charAt(0)=='b') || (s.charAt(0)=='c') || (s.charAt(0)=='d') || (s.charAt(0)=='e') || (s.charAt(0)=='f'))
        {
            if(s.charAt(1)=='1' || s.charAt(1)=='8')c+=5;
            else c+=8;
        }

        System.out.println(c);

    }
}

import java.util.Scanner;

/**
 *
 * @author toshiba
 */
public class Tests {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();

         if((str.charAt(0) == 'a' && str.charAt(1) == '1')|| (str.charAt(0) == 'a' && str.charAt(1) == '8')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '1') || (str.charAt(0) == 'h' && str.charAt(1) == '8'))
            System.out.println(3);
         else if((str.charAt(0) > 97 && str.charAt(0) < 105 && str.charAt(1) == 49 || str.charAt(1) == 56)
                 || (str.charAt(1) > 49 && str.charAt(1) < 56 && str.charAt(0) == 97 && str.charAt(0) == 105))
             System.out.println(5);
         else
             System.out.println(8);
        }

    }

/**
 *
 *
 *
 * @author
 * @version 1.00 2016/10/23
 */

import java.util.*;

public class KingMoves{
	public static void main (String args []){

		Scanner kbd = new Scanner(System.in);
		String s = kbd.nextLine();
		char c = s.charAt(0);
		char r = s.charAt(1);
		int o = 0;

		if (c == 'a' || c == 'h'){
			if (r == '1' || r == '8'){
				o = 3;
			} else{
				o = 5;
			  }

		}if (r == '1' || r == '8'){
			o = 5;
		} else{
			o = 8;
		}
		System.out.print(o);
	}
}

import java.util.*;
public class King_Moves
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String pos;
        int move=8;
        char row,col;
        System.out.println("Enter position");
        pos=sc.next();
        col=pos.charAt(0);
        row=pos.charAt(1);
        if(col=='a'||col=='h')
        {
            if(row=='1'||row=='8')
              move=3;
            else
              move=5;
        }
        else
        if(row=='1'||row=='8')
            move=5;
        System.out.println(move);
    }
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author asus
 */
public class hodikorolya {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String c = in.nextLine();
        String[] s = c.split("");
        String f = s[0];
        int g = Integer.parseInt(s[1]);
        int cde = 0;
        if ((f.equals("a")||f.equals("h")) && (g == 1 || g == 8)) {
            cde=3;
        }
        else if((f.equals("a")||f.equals("h")&&((g != 1 || g != 8)))){
            cde=5;
        }
        else{
            cde=8;
        }
        System.out.println(cde);

    }
}

import java.util.Scanner;

public class Chess {

	enum COLUMN{
		a,b,c,d,e,f,g,h
	};

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String pos=s.nextLine();
		String col=pos.substring(0, 1);
		String row=pos.substring(1, 2);
		int count=0;
		if(Integer.parseInt(row)<1 || Integer.parseInt(row)>8){
			System.out.println(0);
		}
		if(Integer.parseInt(row)!=(COLUMN.a.ordinal()+1) && Integer.parseInt(row)!=(COLUMN.h.ordinal()+1)){
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for up and one for down
				//4 times for Diagonal
				//Twice for Sideways
				count=count+8;
			}
			else{
				//Count should be incremented twice - one for up and one for down
				//2 times for Diagonal
				//1 for left/right
				count=count+5;
			}
		}
		else{
			if(!col.equals(COLUMN.a.toString()) && !row.equals(COLUMN.h.toString())){
				//Count should be incremented twice - one for right and one for left
				//2 times for Diagonals
				//1 for Up/Down
				count=count+5;
			}
			else{
				//These are the corner piece- Hence, 3 moves
				count=count+3;
			}
		}
		System.out.println(count);
	}

}

import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		String str = in.next();

		int x = str.charAt(0) - 'a';
		int y = str.charAt(1) - '0';

		int ans = -1;
		for(int i = x-1; i <= x+1; i++)
			for(int j = y-1; j <= y+1; j++)
				if(x >= 0 && x < 8 && y >= 0 && y < 8)
					ans++;

		System.out.println(ans);

		in.close();
	}
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

         Scanner sc = new Scanner(System.in);
         String s=sc.next();

         if(s.contains("h")||s.contains("a")){
              if(s.contains("1")||s.contains("8"))
             System.out.println("3");}

         else if(s.contains("1")||s.contains("8")||s.contains("h")||s.contains("a")){
             System.out.println("5");
         }
         else
             System.out.println("8");

    }

}

import java.util.Scanner;

public class Chess {

	enum COLUMN{
		a,b,c,d,e,f,g,h
	};

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String pos=s.nextLine();
		String col=pos.substring(0, 1);
		String row=pos.substring(1, 2);
		int count=0;
		if(Integer.parseInt(row)<1 || Integer.parseInt(row)>8){
			System.out.println(0);
		}
		if(!row.equals(COLUMN.a.ordinal()-1) && !row.equals(COLUMN.h.ordinal()-1)){
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for up and one for down
				//4 times for Diagonal
				//Twice for Sideways
				count=count+8;
			}
			else{
				//Count should be incremented twice - one for up and one for down
				//2 times for Diagonal
				//1 for left/right
				count=count+5;
			}
		}
		else{
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for right and one for left
				//2 times for Diagonals
				//1 for Up/Down
				count=count+5;
			}
			else{
				//These are the corner piece- Hence, 3 moves
				count=count+3;
			}
		}
		System.out.println(count);
	}

}

import java.io.*;
import java.util.*;

public class Solution{

 public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

     int n=0;
     String w;

     w=in.nextLine();

     if(w.charAt(0)=='a' || w.charAt(0)=='h')n++;
     if(w.charAt(1)=='1' || w.charAt(1)=='8')n++;

     if(n==0){
         System.out.println("8");
     }
     else if(n==1){
         System.out.println("3");
     }
     else{
         System.out.println("2");
     }
 }
}

import java.util.Scanner;

public class KingMoves {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		String t="";
		int c=0;
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i)>='0' && s.charAt(i)<='9')
			{
				t+=s.charAt(i);
			}
		}
		int a=Integer.parseInt(t);
		if(a<4) System.out.println("3");
		else if(a==4) System.out.println("4");
		else System.out.println("5");
	}

}

//package progteamwarmup;

import java.util.Scanner;

public class CodeForces710A {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String position = in.nextLine();
        char col = position.charAt(0);
        int row = Character.getNumericValue(position.charAt(1));

        int numMoves = 0;
        if (row > 1 && row < 8) //interior row
        {
            if (col != 'a' || col != 'h') //interior of board
            {
                numMoves = 8;
            }
            else                          //interior row exterior col
            {
                numMoves = 5;
            }
        }
        else                              //exterior row
        {
            if (col == 'a' || row == 'h') //exterior row exterior col
            {
                numMoves = 3;
            }
            else                          //exterior row interior col
            {
                numMoves = 5;
            }
        }

        System.out.println(numMoves);

        in.close();
    }

}

import java.io.*;
import java.util.*;

public class Main {

    private static StringBuilder data = new StringBuilder();
    private final static FastReader in = new FastReader();

    public static void main(String[] args) {

      String s=in.line();
     if(s.charAt(0)>'a'&&s.charAt(0)<'h'&&s.charAt(1)>'1'&&s.charAt(1)<'8'){
         System.out.println(8);
     }else if((s.charAt(0)=='1'||s.charAt(0)<'8')&&(s.charAt(1)=='a'&&s.charAt(1)=='h')){
         System.out.println(3);
     }else{
         System.out.println(5);
     }
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int inT() {
            return Integer.parseInt(next());
        }

        long lonG() {
            return Long.parseLong(next());
        }

        float floaT() {
            return Float.parseFloat(next());
        }

        double doublE() {
            return Double.parseDouble(next());
        }

        String line() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.Scanner;

/**
 *
 * @author toshiba
 */
public class Tests {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();

         if((str.charAt(0) == 'a' && str.charAt(1) == '1')
                 || (str.charAt(0) == 'a' && str.charAt(1) == '8')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '1')
                 || (str.charAt(0) == 'h' && str.charAt(1) == '8'))
            System.out.println(3);

         else if((str.charAt(0) >= 97 || str.charAt(0) <= 105
                 && str.charAt(1) == 49 || str.charAt(1) == 56)
                 || (str.charAt(1) >= 49 || str.charAt(1) <= 56
                 && str.charAt(0) == 97 || str.charAt(0) == 105))
             System.out.println(5);

         else
             System.out.println(8);
        }

    }

import java.util.*;

public class cf710a {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String x = in.next();
        char a = x.charAt(0);
        char b= x.charAt(1);

        if ((a == 'a' && b == '8')||(a == 'a' && b == '1')||(a == 'h' && b == '8')||(a == 'h' && b == '1')) {
            System.out.println(3);
        } else if (b == '8' || b == '1') {
            System.out.println(5);
        } else {
            System.out.println(8);
        }

    }

}

import java.util.*;
public class King
{

    public static void main(String[] args)
    {
       Scanner sc=new Scanner(System.in);
       String pos=sc.next();
       if(pos.charAt(0)=='a'||pos.charAt(0)=='h')
       {
          if(pos.charAt(1)=='8'||pos.charAt(1)=='1')
              System.out.println(3);
          else
              System.out.println(5);
       }
       else
           System.out.println(8);
    }

}

import java.util.Scanner;
public class submission {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String cd = sc.nextLine();
		char column = cd.charAt(0);
		int row = Character.getNumericValue(cd.charAt(1));
		//System.out.println(column+ " "+row);
		if(column=='a' || column =='h'){
			if(row==1 || row==8)System.out.println(3);
			else System.out.println(5);
		}else
			System.out.println(8);

	}

}

import java.util.Scanner;

public class Chess {

	enum COLUMN{
		a,b,c,d,e,f,g,h
	};

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String pos=s.nextLine();
		String col=pos.substring(0, 1);
		String row=pos.substring(1, 2);
		int count=0;
		if(Integer.parseInt(row)<1 || Integer.parseInt(row)>8){
			System.out.println(0);
		}
		if(!row.equals(COLUMN.a.ordinal()) && !row.equals(COLUMN.h.ordinal())){
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for up and one for down
				//4 times for Diagonal
				//Twice for Sideways
				count=count+8;
			}
			else{
				//Count should be incremented twice - one for up and one for down
				//2 times for Diagonal
				//1 for left/right
				count=count+5;
			}
		}
		else{
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for right and one for left
				//2 times for Diagonals
				//1 for Up/Down
				count=count+5;
			}
			else{
				//These are the corner piece- Hence, 3 moves
				count=count+3;
			}
		}
		System.out.println(count);
	}

}

import java.util.Scanner;

/**
 * Created by LevDavid on 8/22/2016.
 */
public class HelloWorld {

    public static void main(String[] args) {
        // write your code here
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        if(input.charAt(0)<'h'&&input.charAt(0)>'a'){
            if(input.charAt(1)<'2'||input.charAt(1)>'7'){
                System.out.println(6);
            } else {
                System.out.println(8);
            }
        } else {
            if (input.charAt(1) < '2' || input.charAt(1) > '7') {
                System.out.println(3);
            } else {
                System.out.println(6);
            }
        }
    }
}

import java.util.Scanner;

public class Task_710A {
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        if (a.contains("a") || a.contains("h")) {
            if (a.contains("a") && (a.contains("1") || a.contains("8"))) {
                System.out.print(3);
            } else if (a.contains("a")) System.out.print(5);

            if (a.contains("h") && (a.contains("1") || a.contains("8"))) {
                System.out.print(3);
            } else if (a.contains("h")) System.out.print(5);
        }else System.out.print(8);
    }
}

import java.io.IOException;
import static java.lang.Math.*;
import java.math.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        if(s.equals("a1")||s.equals("h1")||s.equals("h8")||s.equals("a8"))
            System.out.println(3);
        else if(s.charAt(0)=='a'||s.charAt(0)=='h')
            System.out.println(5);
        else
            System.out.println(8);
    }

    static int prime(int p) {
        int t = (int) sqrt(Integer.parseInt(p + ""));
        if (t <= 1) {
            return 0;
        }
        for (long i = 2; i <= t; i++) {
            if (p % i == 0) {
                return 0;
            }

        }
        return 1;
    }

    static int Obe(long a, long b) {
        BigInteger b1 = new BigInteger("" + a);
        BigInteger b2 = new BigInteger("" + b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    static int che(int[] w) {
        Set<Integer> list = new LinkedHashSet<>();
        for (int i = 0; i < w.length; i++) {
            list.add(w[i]);
        }
        return list.size();
    }

    private static ArrayList<BigInteger> fibCache = new ArrayList<BigInteger>();

    static {
        fibCache.add(BigInteger.ZERO);
        fibCache.add(BigInteger.ONE);
    }

    public static BigInteger fib(int n) {
        if (n >= fibCache.size()) {
            fibCache.add(n, fib(n - 1).add(fib(n - 2)));
        }

        return fibCache.get(n);
    }

}

import java.util.Scanner;

public class king {
	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		String cd=sca.next();
		char c = cd.charAt(0);
		char d = cd.charAt(1);
		if (cd == "a1" || cd == "a8" || cd == "h1" || cd == "h8") {
			System.out.println(3);
		} else if (c == 'a' || c == 'h' || d == '1' || d == '8') {
			System.out.println(5);
		} else {
			System.out.println(8);
		}
	}
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author asus
 */
public class hodikorolya {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String c = in.nextLine();
        String[] s = c.split("");
        String f = s[0];
        int g = Integer.parseInt(s[1]);
        int cde = 0;
        if ((f.equals("a")||f.equals("h")) && ((g == 1 || g == 8))) {
            cde=3;
        }
        if((f.equals("a")||f.equals("h"))&&((g != 1 || g != 8))){
            cde=5;
        }
        if(!f.equals("h")&&!f.equals("a")&& g!=1 && g!=8){
            cde=8;
        }
        System.out.println(cde);

    }
}

import java.util.Scanner;

public class Problem8 {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		String position = input.nextLine();

		if(position.equals("h8") || position.equals("a8") || position.equals("h1") || position.equals("a1"))
			System.out.println("3");
		else if(position.charAt(1) == '1' || position.charAt(1) == '8' || position.charAt(0) == 'a' || position.charAt(1) == 'h')
			System.out.println("5");
		else
			System.out.println("8");

		input.close();
	}

}

import java.util.Scanner;

public class Chess {

	enum COLUMN{
		a,b,c,d,e,f,g,h
	};

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String pos=s.nextLine();
		String col=pos.substring(0, 1);
		String row=pos.substring(1, 2);
		int count=0;
		if(Integer.parseInt(row)<1 || Integer.parseInt(row)>8){
			System.out.println(0);
		}
		if(Integer.parseInt(row)!=(COLUMN.a.ordinal()+1) && Integer.parseInt(row)!=(COLUMN.h.ordinal()+1)){
			if(!col.equals(COLUMN.a.toString()) && !row.equals(COLUMN.h.toString())){
				//Count should be incremented twice - one for up and one for down
				//4 times for Diagonal
				//Twice for Sideways
				count=count+8;
			}
			else{
				//Count should be incremented twice - one for up and one for down
				//2 times for Diagonal
				//1 for left/right
				count=count+5;
			}
		}
		else{
			if(!col.equals(COLUMN.a.toString()) && !col.equals(COLUMN.h.toString())){
				//Count should be incremented twice - one for right and one for left
				//2 times for Diagonals
				//1 for Up/Down
				count=count+5;
			}
			else{
				//These are the corner piece- Hence, 3 moves
				count=count+3;
			}
		}
		System.out.println(count);
	}

}

import java.io.*;
import java.util.*;
import java.util.TreeSet;
import java.lang.*;
import java.text.DecimalFormat;
public class ab{
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		String z=in.next();
		char c=z.charAt(0),r=z.charAt(1);
		if(c=='a'||c=='h'){
			if(r=='1'||r=='8')
				System.out.println(3);
			else
				System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

import java.util.Scanner;

public class JavaApplication57 {

    public static void main(String[] args) {
        Scanner cin=new Scanner (System.in);
        int count=0;
String s=cin.next();
char ch = s.charAt(0);
String ss= ""+s.charAt(1);
int num=Integer.parseInt(ss);
if (ch=='a' || ch=='h'){
if (num==1 || num==8)
    count=3;
else count=5;

}
else count=8;

        System.out.println(count);

    }

}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

         Scanner sc = new Scanner(System.in);
         String s=sc.next();

         if(s.contains("h")||s.contains("a"))
              if(s.contains("1")||s.contains("8"))
             System.out.println("3");

         else if(s.contains("1")||s.contains("8")||s.contains("h")||s.contains("a")){
             System.out.println("5");
         }
         else
             System.out.println("8");

    }

}

import java.io.*;
import java.util.*;

public class KingMoves
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

		String pos = st.nextToken();

		char column = pos.charAt(0);
		int columnindex = (int) column-96;
		int rowindex = Character.getNumericValue(pos.charAt(1));

		if(rowindex>1 && rowindex<8 && columnindex>1 && columnindex<8)
		      System.out.println(8);
		else if((rowindex==8 || rowindex==1) && (columnindex>1 || columnindex<8))
		      System.out.println(5);
	      else if((rowindex>1 || rowindex<8) && (columnindex==1 || columnindex==8))
		      System.out.println(5);
	      else
	            System.out.println(3);

	}
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if (s.contains("h") || s.contains("a")) {
            if (s.contains("1") || s.contains("8")) {
                System.out.println("3");
            } else if (s.contains("1") || s.contains("8") || s.contains("h") || s.contains("a")) {
                System.out.println("5");
            } else {
                System.out.println("8");
            }
        }
        else
            System.out.println("8");

    }

}

import java.util.*;

public class A710 {
    public static boolean isEdge(int x) {
        return x == 1 || x == 8;
    }

    public static boolean isCorner(int x, int y) {
        return isEdge(x) && isEdge(y);
    }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String str = scan.next();

		int a = (int)(str.charAt(0) - 'a') + 1;
		int b = str.charAt(1);

		System.out.println(a);
		System.out.println(b);

		int ans = 8;
		if (isCorner(a, b)) {
		    ans = 3;
		}
		else if (isEdge(a) || isEdge(b)) {
		    ans = 5;
		}

		System.out.print(ans);
	}
}

import java.util.*;

public class A710 {
    public static boolean isEdge(int x) {
        return x == 1 || x == 8;
    }

    public static boolean isCorner(int x, int y) {
        return isEdge(x) && isEdge(y);
    }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String str = scan.next();

		int a = str.charAt(0) - 'a' + 1;
		int b = str.charAt(1);

		int ans = 8;
		if (isCorner(a, b)) {
		    ans = 3;
		}
		else if (isEdge(a) || isEdge(b)) {
		    ans = 5;
		}

		System.out.print(ans);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            int n = (x.charAt(0) - 'a' + 1) + (x.charAt(1) - '0') * 8;
            if (n == 1 || n == 8 || n == 57 || n == 64) {
                out.println(3);
            } else if (n % 8 == 1 || n % 8 == 0) {
                out.println(5);
            } else {
                out.println(8);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}

import java.io.*;
import java.util.*;

public class Solution{

 public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

     int n=0;
     String w;

     w=in.nextLine();

     if(w.charAt(0)=='a' || w.charAt(0)=='h')n++;
     if(w.charAt(1)=='1' || w.charAt(1)=='8')n++;

     if(n==0){
         System.out.println("8");
     }
     else if(n==1){
         System.out.println("3");
     }
     else{
         System.out.println("2");
     }
 }
}

import java.util.*;
public class Training{
	public static void main(String[]args){
	Scanner inp = new Scanner(System.in);
	String in = inp.next();
	char c = in.charAt(0);
	int d = in.charAt(1);
	int move;
	if(c=='a'||c=='h')
		if(d>=2||d<=7)
			move = 5;
		else
			move = 3;
	else
		move = 8;
	System.out.print(move);
	}
}

import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		String str = in.next();

		int x = str.charAt(0) - 'a';
		int y = str.charAt(1) - '0';

		int ans = -1;
		for(int i = x-1; i <= x+1; i++)
			for(int j = y-1; j <= y+1; j++)
				if(i >= 0 && i < 8 && j >= 0 && j < 8)
					ans++;

		System.out.println(ans);

		in.close();
	}
}

import java.util.Scanner;

public class DashaAndStairs {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		if(a.equals("aa") || a.equals("ha") ||a.equals("ah") || a.equals("hh")||
				a.equals("a1") || a.equals("h1") ||a.equals("a8") || a.equals("h8"))
			System.out.println(3);
		else if (a.contains("a") || a.contains("h")){
			System.out.println(5);
		}
		else
			System.out.println(8);

	}

}

import java.util.Scanner;

public class Tester {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			String s;
			Scanner sc = new Scanner(System.in);
			s = sc.nextLine();
			if(s.charAt(0)=='a' || s.charAt(0) == 'h')
			{
				if(s.charAt(1)-49==0|| s.charAt(1)-56==0)
						{
								System.out.println(3);
						}
				else
					System.out.println(5);
			}
			else
				System.out.println(8);
	}

}

import java.util.Scanner;

public class W {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String cd = in.next();
		char c = cd.charAt(0);
		char d = cd.charAt(1);
		int q=4;
		int r=3;
		int z=2;
		  if (("bcdefg".indexOf(c) >= 0)&&("234567".indexOf(d)>= 0)) {
		   	   System.out.println(q);};
		   if (("bcdefg".indexOf(c) >= 0)&&("18".indexOf(d)>= 0)) {
				System.out.println(r);};
		    if (("ah".indexOf(c) >= 0)&&("234567".indexOf(d)>= 0)) {
				 System.out.println(r);};
		    if (("ah".indexOf(c) >= 0)&&("18".indexOf(d)>= 0)) {
				 System.out.println(z);};

	}

}

    import java.util.*;
    import java.lang.*;
    import java.io.*;

    public class S{
        public static void main(String[] args) {
		String s1;
		Scanner sc = new Scanner(System.in);
		String position = sc.nextLine();
		System.out.println(kingMoves(position));
	}

	public static int kingMoves(String position) {
		int x = Character.getNumericValue(position.charAt(0));
		int y = Character.getNumericValue(position.charAt(1));

		int moves =0;

		System.out.println(x+" and "+y);

		if( (x==10 || x==17) && (y==1 || y==8)) {
			moves+=3;
		}else if( (x>10 && x<17 && y==1) || (x>10 && x<17 && y==8) || (y>1 && y<8 && x==10) || (y>1 && y<8 && x==17)) {
			moves+=5;
		}else if(x>10 && x<17 && y>1 && y<8){
			moves+=8;
		}

		return moves;
	}
    }

import java.util.*;
public class Dice
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String z=sc.next();
		char c=z.charAt(0);
		char r=z.charAt(1);
		int m=0;
		if((c=='a' && r=='1') || (c=='h' && r=='1') || (c=='h' && r=='8') || (c=='a' && r=='8'))
		m=3;
		else if((c!='a' && r=='1') || (c!='h' && r=='1') || (c!='h' && r=='8') || (c!='a' && r=='8'))
		m=5;
		else
		m=8;
System.out.println(m);

}
}

import java.io.IOException;
import static java.lang.Math.*;
import java.math.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        if(s.equals("a1")||s.equals("h1")||s.equals("h8")||s.equals("a8"))
            System.out.println(3);
        else if(s.charAt(0)=='a'||s.charAt(0)=='h'||s.charAt(1)=='1'||s.charAt(0)=='8')
            System.out.println(5);
        else
            System.out.println(8);
    }

    static int prime(int p) {
        int t = (int) sqrt(Integer.parseInt(p + ""));
        if (t <= 1) {
            return 0;
        }
        for (long i = 2; i <= t; i++) {
            if (p % i == 0) {
                return 0;
            }

        }
        return 1;
    }

    static int Obe(long a, long b) {
        BigInteger b1 = new BigInteger("" + a);
        BigInteger b2 = new BigInteger("" + b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    static int che(int[] w) {
        Set<Integer> list = new LinkedHashSet<>();
        for (int i = 0; i < w.length; i++) {
            list.add(w[i]);
        }
        return list.size();
    }

    private static ArrayList<BigInteger> fibCache = new ArrayList<BigInteger>();

    static {
        fibCache.add(BigInteger.ZERO);
        fibCache.add(BigInteger.ONE);
    }

    public static BigInteger fib(int n) {
        if (n >= fibCache.size()) {
            fibCache.add(n, fib(n - 1).add(fib(n - 2)));
        }

        return fibCache.get(n);
    }

}

import java.util.Scanner;
public class chess{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		   String s=sc.nextLine();
            if(s.charAt(0)=='a'||s.charAt(0)=='h')
            {
            	if(s.charAt(1)!='8'&&s.charAt(1)!='1')
            	System.out.println(5);
            	else
            	System.out.println(3);
            }
            else
            	System.out.println(8);
	}
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author asus
 */
public class hodikorolya {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        String c = in.nextLine();
        String[] s = c.split("");
        String f = s[0];
        int g = Integer.parseInt(s[1]);
        int cde = 0;
        if ((f.equals("a")||f.equals("h")) && ((g == 1 || g == 8))) {
            cde=3;
        }
        if((f.equals("a")||f.equals("h"))&&((g != 1 || g != 8))){
            cde=5;
        }
        if(!f.equals("h")&&!f.equals("a")&& g!=1 && g!=8){
            cde=8;
        }
        System.out.println(cde);

    }
}

import java.util.*;
public class King_Moves
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String pos;
        int move=8;
        char row,col;
        System.out.println("Enter position");
        pos=sc.next();
        col=pos.charAt(0);
        row=pos.charAt(1);
        if(col=='a'||col=='h')
        {
            if(row=='1'||row=='8')
              move=3;
            else
              move=5;
        }
        else
        if(row=='1'||row=='8')
            move=5;
        System.out.println(move);
    }
}

import java.util.*;
public class sfirst{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String arip = "abcdefgh";
		String s = scn.nextLine();
		int a = arip.indexOf(s.split("")[0])+1;
		int b = Integer.parseInt(s.split("")[1]);
		if(b > a){
			int h = a;
			a = b;
			b = h;
		}
		if ((a == 1 && b ==1) || (a == 8 && b ==8)) {
			System.out.println(3);
		}
		else if((a == 1 || b ==1) || (a == 8 || b ==8)){
			System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

         Scanner sc = new Scanner(System.in);
         String s=sc.next();

         if(s.contains("h")||s.contains("a")&&s.contains("1")||s.contains("8")){
             System.out.println("3");
         }
         else if(s.contains("1")||s.contains("8")){
             System.out.println("5");
         }
         else
             System.out.println("8");

    }

}

import java.util.*;

public class A710 {
    public static boolean isEdge(int x) {
        return x == 1 || x == 8;
    }

    public static boolean isCorner(int x, int y) {
        return isEdge(x) && isEdge(y);
    }

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String str = scan.next();

		int a = str.charAt(0) - 'a' + 1;
		int b = str.charAt(1);

		int ans = 8;
		if (isCorner(a, b)) {
		    ans = 3;
		}
		else if (isEdge(a) || isEdge(b)) {
		    ans = 5;
		}

		System.out.print(ans);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            int n = (x.charAt(0) - 'a') * 8 + (x.charAt(1) - '0');
            if (n == 1 || n == 8 || n == 57 || n == 64) {
                out.println(3);
            } else if (n % 8 == 1 || n % 8 == 0) {
                out.println(5);
            } else {
                out.println(8);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}

/**
 *
 *
 *
 * @author
 * @version 1.00 2016/10/23
 */

import java.util.*;

public class KingMoves{
	public static void main (String args []){

		Scanner kbd = new Scanner(System.in);
		String s = kbd.nextLine();
		char c = s.charAt(0);
		char r = s.charAt(1);
		int o = 0;

		if (c == 'a' || c == 'h'){
			if (r == '1' || r == '8'){
				o = 3;
			} else{
				o = 5;
			  }

		}if (r == '1' || r == '8'){
			o = 5;
		} else{
			o = 8;
		}
		System.out.print(o);
	}
}

import java.util.*;
public class sfirst{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String arip = "abcdefgh";
		String s = scn.nextLine();
		int a = arip.indexOf(s.split("")[0])+1;
		int b = Integer.parseInt(s.split("")[1]);
		if(b > a){
			int h = a;
			a = b;
			b = h;
		}
		if ((a == 1 && b ==1) || (a == 8 && b ==8) || (a == 1 && b == 8)) {
			System.out.println(3);
		}
		else if((a == 1 || b ==1) || (a == 8 || b ==8) ||  (a == 1 || b == 8)){
			System.out.println(5);
		}
		else
			System.out.println(8);
	}
}

// http://codeforces.com/problemset/problem/710/A

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		Scanner read = new Scanner(System.in);

		String position = read.nextLine();

		Map<Character, Integer> columnNumbers = new HashMap<Character, Integer>();
		int columnNumber = 0;
		for (char c = 'a'; c <= 'h'; ++c) {
			columnNumbers.put(c, columnNumber);
			columnNumber++;
		}

		int kingRowNumber = Math.abs(9 - Character.getNumericValue(position.charAt(1)) );
		int kingColumnNumber = columnNumbers.get(position.charAt(0));
		int numberOfValidMoves = 0;

		boolean canMoveUp = kingRowNumber-1 >= 1;
		boolean canMoveDown = kingRowNumber+1 <= 8;
		boolean canMoveLeft = kingColumnNumber-1 >= 1;
		boolean canMoveRight = kingColumnNumber+1 <= 8;
		boolean canMoveUpLeftDiagonally = canMoveUp && canMoveLeft;
		boolean canMoveUpRightDiagonally = canMoveUp && canMoveRight;
		boolean canMoveDownLeftDiagonally = canMoveDown && canMoveLeft;
		boolean canMoveDownRightDiagonally = canMoveDown && canMoveRight;

		if (canMoveUp) { numberOfValidMoves++; }
		if (canMoveDown) { numberOfValidMoves++; }
		if (canMoveLeft) { numberOfValidMoves++; }
		if (canMoveRight) { numberOfValidMoves++; }
		if (canMoveUpLeftDiagonally) { numberOfValidMoves++; }
		if (canMoveUpRightDiagonally) { numberOfValidMoves++; }
		if (canMoveDownLeftDiagonally) { numberOfValidMoves++; }
		if (canMoveDownRightDiagonally) { numberOfValidMoves++; }

		System.out.println(numberOfValidMoves);

		// Close scanner
		read.close();
	}
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if (s.contains("h") || s.contains("a")) {
            if (s.contains("1") || s.contains("8")) {
                System.out.println("3");
            } else if (s.contains("1") || s.contains("8") || s.contains("h") || s.contains("a")) {
                System.out.println("5");
            } else {
                System.out.println("8");
            }
        }
        else
            System.out.println("8");

    }

}

import java.lang.*;
import java.util.*;
public class Cf1 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char c = s.charAt(0);
		char d = s.charAt(1);
		if(c=='a' || c=='h')
		{
			if(d=='1' || d=='8')
			{
				System.out.println("3");
			}
			else
			{
				System.out.println("5");
			}
		}
		else
		{
			if(d=='1' || d=='8')
			{
				System.out.println("3");
			}
			else
			{
			System.out.println("8");
			}
		}
	}

}

import java.util.Scanner;

public class Chess {

	enum COLUMN{
		a,b,c,d,e,f,g,h
	};

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String pos=s.nextLine();
		String col=pos.substring(0, 1);
		String row=pos.substring(1, 2);
		int count=0;
		if(Integer.parseInt(row)<1 || Integer.parseInt(row)>8){
			System.out.println(0);
		}
		if(!row.equals(COLUMN.a.ordinal()) && !row.equals(COLUMN.h.ordinal())){
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for up and one for down
				//4 times for Diagonal
				//Twice for Sideways
				count=count+8;
			}
			else{
				//Count should be incremented twice - one for up and one for down
				//2 times for Diagonal
				//1 for left/right
				count=count+5;
			}
		}
		else{
			if(!col.equals(COLUMN.a) && !row.equals(COLUMN.h)){
				//Count should be incremented twice - one for right and one for left
				//2 times for Diagonals
				//1 for Up/Down
				count=count+5;
			}
			else{
				//These are the corner piece- Hence, 3 moves
				count=count+5;
			}
		}
		System.out.println(count);
	}

}

import java.util.Scanner;

public class Tester {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			String s;
			Scanner sc = new Scanner(System.in);
			s = sc.nextLine();
			if(s.charAt(0)=='a' || s.charAt(0) == 'h')
			{
				if(s.charAt(1)-49==0|| s.charAt(1)-56==0)
						{
								System.out.println(3);
						}
				else
					System.out.println(5);
			}
			else
				System.out.println(8);
	}

}

import java.util.Scanner;
public class chess{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		   String s=sc.nextLine();
            if(s.charAt(0)=='a'||s.charAt(0)=='h')
            {
            	if(s.charAt(1)=='8'||s.charAt(1)=='1')
            	System.out.println(3);
            	else
            	System.out.println(5);
            }
            else
            	System.out.println(8);
	}
}

import java.util.Scanner;

public class JavaApplication57 {

    public static void main(String[] args) {
        Scanner cin=new Scanner (System.in);
        int count=0;
String s=cin.next();
char ch = s.charAt(0);
String ss= ""+s.charAt(1);
int num=Integer.parseInt(ss);
if (ch=='a' || ch=='h'){
if (num==1 || num==8)
    count=3;
else count=5;

}
else count=8;

        System.out.println(count);

    }

}

import java.io.*;
import java.util.*;
import java.util.TreeSet;
import java.lang.*;
import java.text.DecimalFormat;
public class ab{
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		String z=in.next();
		char c=z.charAt(0),r=z.charAt(1);
		if(c=='a'||c=='h'){
			if(r=='1'||r=='8')
				System.out.println(3);
			else
				System.out.println(6);
		}
		else
			System.out.println(8);
	}
}

import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String position = in.next();
            char col = position.charAt(0);
            int row = Integer.valueOf(String.valueOf(position.charAt(1)));
            int result = 8;
            boolean inEdge = false;
            if (row == 1 || row == 8) {
                result -= 3;
                inEdge = true;
            }
            if (col == 'a' || row == 'h') {
                result -= 3;
                if (inEdge) result = 3;
            }
            System.out.println(result);
        }
    }
}

import java.util.Scanner;

public class A710 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if (s.contains("h") || s.contains("a") ) {
            if (s.contains("1") || s.contains("8")) {
                System.out.println("3");
            }
      //  } else {

           else if (s.contains("1") || s.contains("8") || s.contains("h") || s.contains("a")) {
                System.out.println("5");
            } else {
                System.out.println("8");
            }
        }

    }

}

import java.util.Scanner;

public class Chess {

	enum COLUMN{
		a,b,c,d,e,f,g,h
	};

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String pos=s.nextLine();
		String col=pos.substring(0, 1);
		String row=pos.substring(1, 2);
		int count=0;
		String str="abcdefgh";
		if(Integer.parseInt(row)<1 || Integer.parseInt(row)>8){
			System.out.println(0);
			return;
		}
		if(!str.contains(col)){
			System.out.println(0);
			return;
		}
		if(Integer.parseInt(row)!=(COLUMN.a.ordinal()+1) && Integer.parseInt(row)!=(COLUMN.h.ordinal()+1)){
			if(!col.equals(COLUMN.a.toString()) && !row.equals(COLUMN.h.toString())){
				//Count should be incremented twice - one for up and one for down
				//4 times for Diagonal
				//Twice for Sideways
				count=count+8;
			}
			else{
				//Count should be incremented twice - one for up and one for down
				//2 times for Diagonal
				//1 for left/right
				count=count+5;
			}
		}
		else{
			if(!col.equals(COLUMN.a.toString()) && !col.equals(COLUMN.h.toString())){
				//Count should be incremented twice - one for right and one for left
				//2 times for Diagonals
				//1 for Up/Down
				count=count+5;
			}
			else{
				//These are the corner piece- Hence, 3 moves
				count=count+3;
			}
		}
		System.out.println(count);
	}

}

//package progteamwarmup;

import java.util.Scanner;

public class CodeForces710A {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String position = in.nextLine();
        char col = position.charAt(0);
        int row = Character.getNumericValue(position.charAt(1));

        int numMoves = 0;
        if (row > 1 && row < 8) //interior row
        {
            if (col != 'a' || col != 'h') //interior of board
            {
                numMoves = 8;
            }
            else                          //interior row exterior col
            {
                numMoves = 5;
            }
        }
        else                              //exterior row
        {
            if (col == 'a' || row == 'h') //exterior row exterior col
            {
                numMoves = 3;
            }
            else                          //exterior row interior col
            {
                numMoves = 5;
            }
        }

        System.out.println(numMoves);

        in.close();
    }

}