public static void main ( String [ ] args ) {
  final Scanner sc = new Scanner ( System . in ) ;
  int a = sc . nextInt ( ) ;
  int b = sc . nextInt ( ) ;
  String sa = String . valueOf ( a ) ;
  String sb = String . valueOf ( b ) ;
  int topa = Integer . parseInt ( sa . substring ( 0 , 1 ) ) ;
  int topb = Integer . parseInt ( sb . substring ( 0 , 1 ) ) ;
  int seca = Integer . parseInt ( String . valueOf ( a ) . substring ( 1 , 2 ) ) ;
  int secb = Integer . parseInt ( String . valueOf ( b ) . substring ( 1 , 2 ) ) ;
  int a3 = Integer . parseInt ( String . valueOf ( a ) . substring ( 2 , 3 ) ) ;
  int b3 = Integer . parseInt ( String . valueOf ( b ) . substring ( 2 , 3 ) ) ;
  long ans = a - b ;
  for ( int i = 1 ;
  i <= 9 ;
  i ++ ) {
    ans = Math . max ( 100 * i + a % 100 - b , ans ) ;
    ans = Math . max ( a - 100 * i - b % 100 , ans ) ;
  }
  for ( int i = 0 ;
  i <= 9 ;
  i ++ ) {
    ans = Math . max ( ans , 100 * topa + 10 * i + a3 - b ) ;
    ans = Math . max ( ans , a - 100 * topb - 10 * i - b3 ) ;
    ans = Math . max ( ans , 100 * topa + 10 * seca + i - b ) ;
    ans = Math . max ( ans , a - 100 * topb - 10 * secb - i ) ;
  }
  System . out . println ( ans ) ;
}

public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String sa = String . valueOf ( a ) ; String sb = String . valueOf ( b ) ; int topa = Integer . parseInt ( sa . substring ( 0 , 1 ) ) ; int topb = Integer . parseInt ( sb . substring ( 0 , 1 ) ) ; int seca = Integer . parseInt ( String . valueOf ( a ) . substring ( 1 , 2 ) ) ; int secb = Integer . parseInt ( String . valueOf ( b ) . substring ( 1 , 2 ) ) ; int a3 = Integer . parseInt ( String . valueOf ( a ) . substring ( 2 , 3 ) ) ; int b3 = Integer . parseInt ( String . valueOf ( b ) . substring ( 2 , 3 ) ) ; long ans = a - b ; for ( int i = 1 ; i <= 9 ; i ++ ) { ans = Math . max ( 100 * i + a % 100 - b , ans ) ; ans = Math . max ( a - 100 * i - b % 100 , ans ) ; } for ( int i = 0 ; i <= 9 ; i ++ ) { ans = Math . max ( ans , 100 * topa + 10 * i + a3 - b ) ; ans = Math . max ( ans , a - 100 * topb - 10 * i - b3 ) ; ans = Math . max ( ans , 100 * topa + 10 * seca + i - b ) ; ans = Math . max ( ans , a - 100 * topb - 10 * secb - i ) ; } System . out . println ( ans ) ; }
(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 (modifiers) 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: (integral_type) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (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 (binary_expression left: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier))))))) (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) (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (identifier)) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (identifier)) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))