static void tc ( ) {
  long n = scan . nextLong ( ) ;
  long a = 0l ;
  long b = 0l ;
  int ctr = 0 ;
  while ( n > 0 ) {
    if ( ctr % 2 == 0 ) {
      if ( n % 2 == 0 ) {
        if ( ( n / 2 ) % 2 == 0 && n > 4 ) {
          a += 1 ;
          -- n ;
        }
        else {
          a += n / 2 ;
          n /= 2 ;
        }
      }
      else {
        a += 1 ;
        -- n ;
      }
    }
    else {
      if ( n % 2 == 0 ) {
        if ( ( n / 2 ) % 2 == 0 && n > 4 ) {
          b += 1 ;
          -- n ;
        }
        else {
          b += n / 2 ;
          n /= 2 ;
        }
      }
      else {
        b += 1 ;
        -- n ;
      }
    }
    ++ ctr ;
  }
  System . out . println ( a ) ;
}

static void tc ( ) { long n = scan . nextLong ( ) ; long a = 0l ; long b = 0l ; int ctr = 0 ; while ( n > 0 ) { if ( ctr % 2 == 0 ) { if ( n % 2 == 0 ) { if ( ( n / 2 ) % 2 == 0 && n > 4 ) { a += 1 ; -- n ; } else { a += n / 2 ; n /= 2 ; } } else { a += 1 ; -- n ; } } else { if ( n % 2 == 0 ) { if ( ( n / 2 ) % 2 == 0 && n > 4 ) { b += 1 ; -- n ; } else { b += n / 2 ; n /= 2 ; } } else { b += 1 ; -- n ; } } ++ ctr ; } System . out . println ( a ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (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: (decimal_integer_literal))) (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: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier)))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))