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

public class Main {
  public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String input = scanner.next();
            if(input.length() <= 8 || !getMatch(input) || containsRepeat(input,0, 3)) {
                System.out.println("NG");
            } else {
                System.out.println("OK");
            }
        }
    }


    // 是否长度大于2的子串,即只要包含长度大于3的子串则返回true
    private static boolean containsRepeat(String input, int start, int end) {
       if(end > input.length()) {
           return false;
       }
      if (input.substring(end).contains(input.substring(start, end))){
          return true;
      }
      return containsRepeat(input, start +1, end+1);
    }

    private static boolean getMatch(String input) {
        int count = 0;
        Pattern pattern = Pattern.compile("[A-Z]");
        if(pattern.matcher(input).find()){
            count++;
        }
        Pattern pattern2 = Pattern.compile("[a-z]");
        if(pattern2.matcher(input).find()){
            count++;
        }
        Pattern pattern3 = Pattern.compile("[0-9]");
        if(pattern3.matcher(input).find()){
            count++;
        }
        Pattern pattern4 = Pattern.compile("[^a-zA-Z0-9]");
        if(pattern4.matcher(input).find()){
            count++;
        }
        return count >= 3 ? true : false;
    }      
}