public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  String s = in . next ( ) ;
  int rookX = s . charAt ( 0 ) - 'a' ;
  int rookY = s . charAt ( 1 ) - '1' ;
  s = in . next ( ) ;
  int knightX = s . charAt ( 0 ) - 'a' ;
  int knightY = s . charAt ( 1 ) - '1' ;
  int [ ] [ ] moves = new int [ ] [ ] {
    {
      1 , 2 }, {
        - 1 , 2 }, {
          1 , - 2 }, {
            - 1 , - 2 }, {
              2 , 1 }, {
                - 2 , 1 }, {
                  2 , - 1 }, {
                    - 2 , - 1 }
                  };
                  int answer = 0 ;
                  for ( int x = 0 ;
                  x < 8 ;
                  x ++ ) {
                    if ( x == rookX ) continue ;
                    for ( int y = 0 ;
                    y < 8 ;
                    y ++ ) {
                      if ( y == rookY ) continue ;
                      if ( x == knightX && y == knightY ) continue ;
                      boolean ok = true ;
                      for ( int [ ] move : moves ) {
                        int beatX = x + move [ 0 ] ;
                        int beatY = y + move [ 1 ] ;
                        if ( ( beatX == rookX && beatY == rookY ) || ( beatX == knightX && beatY == knightY ) ) {
                          ok = false ;
                          break ;
                        }
                      }
                      if ( ok ) {
                        answer ++ ;
                      }
                    }
                  }
                  System . out . println ( answer ) ;
                }
                
public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int rookX = s . charAt ( 0 ) - ' a ' ; int rookY = s . charAt ( 1 ) - '1' ; s = in . next ( ) ; int knightX = s . charAt ( 0 ) - ' a ' ; int knightY = s . charAt ( 1 ) - '1' ; int [ ] [ ] moves = new int [ ] [ ] { { 1 , 2 } , { - 1 , 2 } , { 1 , - 2 } , { - 1 , - 2 } , { 2 , 1 } , { - 2 , 1 } , { 2 , - 1 } , { - 2 , - 1 } } ; int answer = 0 ; for ( int x = 0 ; x < 8 ; x ++ ) { if ( x == rookX ) continue ; for ( int y = 0 ; y < 8 ; y ++ ) { if ( y == rookY ) continue ; if ( x == knightX && y == knightY ) continue ; boolean ok = true ; for ( int [ ] move : moves ) { int beatX = x + move [ 0 ] ; int beatY = y + move [ 1 ] ; if ( ( beatX == rookX && beatY == rookY ) || ( beatX == knightX && beatY == knightY ) ) { ok = false ; break ; } } if ( ok ) { answer ++ ; } } } System . out . println ( answer ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (array_initializer (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal))) (array_initializer (unary_expression operand: (decimal_integer_literal)) (unary_expression operand: (decimal_integer_literal))) (array_initializer (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal))) (array_initializer (unary_expression operand: (decimal_integer_literal)) (unary_expression operand: (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (continue_statement)) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (continue_statement)) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (enhanced_for_statement type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) value: (identifier) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (break_statement))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (expression_statement (update_expression (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))