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