<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check(raw, length=8, freq=0, min_types=3, level=STRONG):
 """Check the safety level of the password. :param raw: raw text password. :param length: minimal length of the password. :param freq: minimum frequency. :param min_types: minimum character family. :param level: minimum level to validate a password. """

    raw = to_unicode(raw)
    if level > STRONG:
        level = STRONG

    if len(raw) < length:
        return Strength(False, 'terrible', 'password is too short')

    if is_asdf(raw) or is_by_step(raw):
        return Strength(False, 'simple', 'password has a pattern')

    if is_common_password(raw, freq=freq):
        return Strength(False, 'simple', 'password is too common')

    types = 0

    if LOWER.search(raw):
        types += 1

    if UPPER.search(raw):
        types += 1

    if NUMBER.search(raw):
        types += 1

    if MARKS.search(raw):
        types += 1

    if types < 2:
        return Strength(level <= SIMPLE, 'simple', 'password is too simple')

    if types < min_types:
        return Strength(level <= MEDIUM, 'medium',
                        'password is good enough, but not strong')

    return Strength(True, 'strong', 'password is perfect')