






def 						snake_case      (UpperCAmelCase__			,					UpperCAmelCase__ = 1_0_0_0						) ->       str:
  if (not isinstance(UpperCAmelCase__			,					UpperCAmelCase__						)) or (digit_position <= 0):
    raise ValueError('Digit position must be a positive integer'						)
  elif (not isinstance(UpperCAmelCase__			,					UpperCAmelCase__						)) or (precision < 0):
    raise ValueError('Precision must be a nonnegative integer'						)

  # compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
  # accurate
  UpperCamelCase_:      Dict					   =       (
      4 * _subsum(UpperCAmelCase__			,					1			,					UpperCAmelCase__						)
      - 2 * _subsum(UpperCAmelCase__			,					4			,					UpperCAmelCase__						)
      - _subsum(UpperCAmelCase__			,					5			,					UpperCAmelCase__						)
      - _subsum(UpperCAmelCase__			,					6			,					UpperCAmelCase__						)
  )

  # return the first hex digit of the fractional part of the result
  return hex(int((sum_result % 1) * 1_6						)						)[2:]

def 						snake_case      (UpperCAmelCase__			,					UpperCAmelCase__			,					UpperCAmelCase__						) ->       float:
  UpperCamelCase_:      List[Any]					   =       0.0
  for sum_index in range(digit_pos_to_extract + precision						):
    UpperCamelCase_:      Dict					   =       8 * sum_index + denominator_addend
    if sum_index < digit_pos_to_extract:
      # if the exponential term is an integer and we mod it by the denominator
      # before dividing, only the integer part of the sum will change;
      # the fractional part will not
      UpperCamelCase_:      Union[str, Any]					   =       pow(
          1_6			,					digit_pos_to_extract - 1 - sum_index			,					UpperCAmelCase__						)
    else:
      UpperCamelCase_:      Optional[int]					   =       pow(1_6			,					digit_pos_to_extract - 1 - sum_index						)
    total += exponential_term / denominator
  return total


if __name__ == "__main__":
   import doctest

   doctest.testmod()







def 						snake_case      (UpperCAmelCase__ = 4_0_0_0_0_0_0						) ->       int:

  if n <= 1:
    return 0
  UpperCamelCase_:      Dict					   =       0
  UpperCamelCase_:      Union[str, Any]					   =       2
  UpperCamelCase_:      int					   =       0
  while 4 * b + a <= n:
    UpperCamelCase_   ,UpperCamelCase_:      List[str]					   =       b, 4 * b + a
    count += a
  return count + b


if __name__ == "__main__":
   print(F'''{solution() = }''')