def solve(tokens):
    """
    Given a list of tokens where
    each token is subdivided into
    a frequency range, a character,
    and a string, count the total
    number of tokens that are valid
    where a token is valid if and only
    if the frequency of the character
    appearing in the given string lies
    in the given frequency range.

    :param tokens: A list of tokens.

    :return: The answer required.
    """

    valid = 0

    for line in tokens:
        freq, char, string = line.split(" ")
        actual_char = char[:-1]
        low, high = list(map(int, freq.split("-")))
        if low <= string.count(actual_char) <= high:
            valid += 1

    return valid