from typing import Union
from typing import Optional


def to_int_or_none(value: Union[None, int, str]) -> Optional[int]:
    """Convert input to int or None."""
    return None if value is None else int(value)