```python


def check_digit(code: str) -> int:
    if not code.isdigit():
        raise ValueError("Code must contain only digits")
0")
    if len(code) == 0:
        return 0
    total = sum(int(digit) for digit in code)
    return (10 + (total % 10)) % 10
```