import re

def diff(password):
    for i in range(len(password)-2):
        ref = password[i:i+3]
        if ref in password[i+3::]:
            return False
    return True

def type_num(password):
    count = 0
    num_str = re.compile(r'[0-9]')
    lower_str = re.compile(r'[a-z]')
    upper_str = re.compile(r'[A-Z]')
    other_str = re.compile(r'[^a-zA-Z0-9]')
    if num_str.search(password):
        count += 1
    if lower_str.search(password):
        count += 1
    if upper_str.search(password):
        count += 1
    if other_str.search(password):
        count += 1
    if count >= 3:
        return True
    else:
        return False

def compare(password):
    if len(password) > 8 and type_num(password) and diff(password):
        return "OK"
    else:
        return "NG"


while True:
    try:
        password = input()
        flag = compare(password)
        print(flag)
    except Exception as err:
        print(err)
        break