#include <iostream>
using namespace std;

bool noDup(string pwd) {
    for (int i = 0; i <= pwd.size() - 6; i++) {
        for (int j = i + 3; j <= pwd.size() - 3; j++) {
            if (pwd.substr(i, 3) == pwd.substr(j, 3)) return false;
        }
    }
    return true;
}
// 0123 456789 (10)
// 0000 000000
int main() {
    string pwd;
    while (cin >> pwd) {
        if (pwd.size() <= 8) {
            cout << "NG" << endl;
            continue;
        }
        bool cap = false, low = false, num = false, other = false;
        for (char c : pwd) {
            if (c >= '0' && c <= '9') num = true;
            else if (c >= 'A' && c <= 'Z') cap = true;
            else if (c >= 'a' && c <= 'z') low = true;
            else other = true;
        }
        if (cap + low + num + other < 3) {
            cout << "NG" << endl;
            continue;
        }
        if (noDup(pwd)) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }
}