import java.util.*;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] argus) {
        Scanner scan = new Scanner(System.in);

        while (scan.hasNextLine()) {
            String str = scan.nextLine();
            if (str.length() <= 8) {
                System.out.println("NG");
                continue;
            }
            if (!match(str)) {
                System.out.println("NG");
                continue;
            }
            if (checkStr(str)) {
                System.out.println("NG");
                continue;
            }


            System.out.println("OK");
        }


    }

    public static boolean checkStr(String input) {
        if (input.length() < 6) {
            return false;
        }
        //取3个字符判断重复
        for (int i = 0; i <= input.length() - 3; i++) {
            for (int j = i+3; j <= input.length() - 3; j++) {
                if (input.substring(i, i+3).equals(input.substring(j , j + 3))) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean match(String input) {
        boolean b1 = Pattern.compile("[A-Z]").matcher(input).find();
        boolean b2 = Pattern.compile("[a-z]").matcher(input).find();
        boolean b3 = Pattern.compile("[0-9]").matcher(input).find();
        boolean b4 = Pattern.compile("[^A-Za-z0-9]").matcher(input).find();
        int count = 0;
        if (b1) {
            count++;
        }
        if (b2) {
            count++;
        }
        if (b3) {
            count++;
        }
        if (b4) {
            count++;
        }
        return count >= 3;
    }
}