import re


def is_valid(policy: str, password: str) -> bool:
    """
    Given a policy (e.g. `1-3 a`) and a password (e.g. `abcde`),
    determine if the password complies with the policy
    """
    char = policy[-1:]
    atleast = int(re.findall("[0-9]+", policy)[0])
    atmost = int(re.findall("[0-9]+", policy)[1])
    assert atleast < atmost

    if atleast <= password.count(char) <= atmost:
        return True

    return False