public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int bias = 100 ;
  int A = sc . nextInt ( ) ;
  int B = sc . nextInt ( ) ;
  if ( A == B ) {
    System . out . println ( 0 ) ;
    System . exit ( 0 ) ;
  }
  HashSet < Integer > fixed = new HashSet < > ( ) ;
  int [ ] dic = new int [ ] {
    1 , 5 , 10 , - 1 , - 5 , - 10 };
    B = Math . abs ( B - A ) + bias ;
    int [ ] dist = new int [ 2 * bias + 1 ] ;
    Arrays . fill ( dist , Integer . MAX_VALUE ) ;
    dist [ bias ] = 0 ;
    myComparator mc = new myComparator ( ) ;
    PriorityQueue < int [ ] > pq = new PriorityQueue < > ( 10 , mc ) ;
    pq . add ( new int [ ] {
      bias , 0 }
      ) ;
      while ( ! fixed . contains ( B ) ) {
        int [ ] cur = pq . poll ( ) ;
        int now = cur [ 0 ] ;
        if ( fixed . contains ( now ) ) continue ;
        fixed . add ( now ) ;
        dist [ now ] = cur [ 1 ] ;
        for ( int w : dic ) {
          if ( ! fixed . contains ( now + w ) ) {
            if ( now + w > 2 * bias || now + w < 0 ) continue ;
            if ( dist [ now + w ] > dist [ now ] + 1 ) {
              dist [ now + w ] = dist [ now ] + 1 ;
              pq . add ( new int [ ] {
                now + w , dist [ now ] + 1 }
                ) ;
              }
            }
          }
        }
        int ans = dist [ B ] ;
        System . out . println ( ans ) ;
      }
      
public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bias = 100 ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A == B ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } HashSet < Integer > fixed = new HashSet < > ( ) ; int [ ] dic = new int [ ] { 1 , 5 , 10 , - 1 , - 5 , - 10 } ; B = Math . abs ( B - A ) + bias ; int [ ] dist = new int [ 2 * bias + 1 ] ; Arrays . fill ( dist , Integer . MAX_VALUE ) ; dist [ bias ] = 0 ; myComparator mc = new myComparator ( ) ; PriorityQueue < int [ ] > pq = new PriorityQueue < > ( 10 , mc ) ; pq . add ( new int [ ] { bias , 0 } ) ; while ( ! fixed . contains ( B ) ) { int [ ] cur = pq . poll ( ) ; int now = cur [ 0 ] ; if ( fixed . contains ( now ) ) continue ; fixed . add ( now ) ; dist [ now ] = cur [ 1 ] ; for ( int w : dic ) { if ( ! fixed . contains ( now + w ) ) { if ( now + w > 2 * bias || now + w < 0 ) continue ; if ( dist [ now + w ] > dist [ now ] + 1 ) { dist [ now + w ] = dist [ now ] + 1 ; pq . add ( new int [ ] { now + w , dist [ now ] + 1 } ) ; } } } } int ans = dist [ B ] ; 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 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: (decimal_integer_literal))) (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)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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 (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (unary_expression operand: (decimal_integer_literal)) (unary_expression operand: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (identifier)))) (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_expr (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (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: (generic_type (type_identifier) (type_arguments (array_type element: (integral_type) dimensions: (dimensions)))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list (decimal_integer_literal) (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (identifier) (decimal_integer_literal)))))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) 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: (array_access array: (identifier) index: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (continue_statement)) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (decimal_integer_literal)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (binary_expression left: (identifier) right: (identifier)) (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))))))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))