//JAVA
//难点应该在需求3.不能有相同长度大于2的子串重复
//用正则表达式

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

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            String str=sc.nextLine();
            if(isLengthQualified(str) && isContentQualified(str) &&!hasDuplicatedString(str))
                System.out.println("OK");
            else
                System.out.println("NG");
        }
        sc.close();
    }
    //1.长度超过8位
    public static boolean isLengthQualified(String s){
        return s.length()>8;
    }
    //2.包括大小写字母.数字.其它符号,以上四种至少三种
    public static boolean isContentQualified(String s){
        int count=0;
        //正则
        String[] str={"[a-z]","[A-Z]","[0-9]","[^a-zA-Z0-9]"};
        for(int i=0;i<str.length;i++){
            Pattern p=Pattern.compile(str[i]);
            Matcher m=p.matcher(s);
            if(m.find())
                count++;
        }
        return count>=3;

    }
    //3.不能有相同长度大于2的子串重复
    public static boolean hasDuplicatedString(String s){
        for(int i=0;i<s.length()-3;i++){
            //可以想象成这个重复的子串长度为1,
            //相当于字符去比较,遍历这个字符串中所有长度为3的子串,
            //剩下的字符串里面是否包含这个子串
            if(s.substring(i+3).contains(s.substring(i,i+3)))
                return true;
        }
        return false;
    }
}