public static void main ( String [ ] args ) {
  FastScanner in = new FastScanner ( ) ;
  OutputStream outputStream = System . out ;
  PrintWriter out = new PrintWriter ( outputStream ) ;
  int a [ ] [ ] = new int [ 26 ] [ 9 ] ;
  for ( int i = 0 ;
  i < 3 ;
  i ++ ) {
    String S = in . n ( ) ;
    a [ S . charAt ( 1 ) - 'a' ] [ S . charAt ( 0 ) - '1' ] ++ ;
  }
  int max = 0 ;
  for ( int c = 0 ;
  c < 26 ;
  c ++ ) {
    for ( int d = 0 ;
    d < 9 ;
    d ++ ) {
      max = Math . max ( max , a [ c ] [ d ] ) ;
    }
  }
  int minKoutsu = 3 - max ;
  max = 0 ;
  for ( int c = 0 ;
  c < 26 ;
  c ++ ) {
    for ( int d = 2 ;
    d < 9 ;
    d ++ ) {
      int count = 0 ;
      for ( int i = - 2 ;
      i <= 0 ;
      i ++ ) {
        if ( a [ c ] [ d + i ] > 0 ) {
          count ++ ;
        }
      }
      max = Math . max ( max , count ) ;
    }
  }
  int minShuntsu = 3 - max ;
  int answer = Math . min ( minKoutsu , minShuntsu ) ;
  System . out . println ( answer ) ;
}

public static void main ( String [ ] args ) { FastScanner in = new FastScanner ( ) ; OutputStream outputStream = System . out ; PrintWriter out = new PrintWriter ( outputStream ) ; int a [ ] [ ] = new int [ 26 ] [ 9 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { String S = in . n ( ) ; a [ S . charAt ( 1 ) - ' a ' ] [ S . charAt ( 0 ) - '1' ] ++ ; } int max = 0 ; for ( int c = 0 ; c < 26 ; c ++ ) { for ( int d = 0 ; d < 9 ; d ++ ) { max = Math . max ( max , a [ c ] [ d ] ) ; } } int minKoutsu = 3 - max ; max = 0 ; for ( int c = 0 ; c < 26 ; c ++ ) { for ( int d = 2 ; d < 9 ; d ++ ) { int count = 0 ; for ( int i = - 2 ; i <= 0 ; i ++ ) { if ( a [ c ] [ d + i ] > 0 ) { count ++ ; } } max = Math . max ( max , count ) ; } } int minShuntsu = 3 - max ; int answer = Math . min ( minKoutsu , minShuntsu ) ; 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)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal)) dimensions: (dimensions_expr (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 (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (update_expression (array_access array: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal))) index: (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: (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 (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 (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (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 (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 (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: (unary_expression operand: (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: (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))