import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
String str = sc.nextLine();
if(str.length()<=8) {
System.out.println("NG");
continue;
}
if(testFuzha(str)<3) {
System.out.println("NG");
continue;
}
if(testzichuan(str,3,0)) {
System.out.println("NG");
continue;
}
System.out.println("OK");
}
}
public static boolean testzichuan(String str,int size,int radix) {
if(size>=str.length()) {
return false;
}
if(str.substring(size).contains(str.substring(radix,size))) {
return true;
}else {
return testzichuan(str, size+1, radix+1);
}
}
public static int testFuzha(String str) {
int m=0;
int len = str.length();
if(len!=str.replaceAll("[a-z]", "").length()) m++ ;
if(len!=str.replaceAll("[A-Z]", "").length()) m++ ;
if(len!=str.replaceAll("[0-9]", "").length()) m++ ;
if(len-str.replaceAll("[a-zA-Z0-9]", "").length()!=0) m++ ;
return m;
}
}