#include<stdio.h>
#include<string.h>
int main(){
int l,k,c,i;//l记录字符串长度,c记录种类,k记录长度超过2子串重复情况
char str[100];
while(scanf("%s",str)!=EOF){
l=strlen(str);
int big,small,digit,other;
big=small=digit=other=0;
for(i=0;i<l;i++){
if(str[i]>='a' && str[i]<='z')small=1;
else if(str[i]>='A' && str[i]<='Z')big=1;
else if(str[i]>='0' && str[i]<='9')digit=1;
else other=1;
}
c=big+small+digit+other;
//记录长度超过2的子串的重复情况,k=0说明没有重复,k=1说明重复了
int j;
for(i=0;i<l-6;i++){
for(j=i+3;j<l-3;j++)
if(str[i]==str[j] && str[i+1]==str[j+1] && str[i+2]==str[j+2]){
k=1;
break;
}
}
if(l>8 && c>=3 && k==0)
printf("OK");
else
printf("NG");
}
return 0;
}