import math


def _ndigits(n):
  """Get number of digits in input number.

  Args:
    n: An `int`.

  Returns:
    The number of digits in input number.

  Raises:
    ValueError: If `n` is not an `int`.
  """
  if not isinstance(n, int):
    raise ValueError(f"`n` must be an integer, but got: "
                     f"{n} with type {type(n).__name__}")
  if n == 0:
    return 1
  return int(math.log10(n)) + 1