import string

def f():
    listi=[0,0,0,0]
    count1=0
    count2=0
    check=[]
    expr=raw_input()
    for i in range(0,len(expr)):
        check.append(0)
    if (expr[0] in ['B','S','D','[']) or ( expr[0] in string.lowercase):
        for i in range(0,len(expr)):
            
            if expr[i] in ['B','b']:
                if (expr[i+1] in ['X','x']) and listi[0]==0 and listi[1]==0:
                    listi[0]=1
                    check[i]=1
                    check[i+1]=1
                else:
                    
                
                    if (expr[i+1] in ['P','p']) and listi[0]==0 and listi[1]==0:
                        listi[1]=1
                        check[i]=1
                        check[i+1]=1
                    else:
                        return 'ERROR'
            if expr[i] in ['s','S']:
                if (expr[i+1] in ['i','I']) and listi[2]==0 and listi[3]==0:
                    listi[2]=1
                    check[i]=1
                    check[i+1]=1
                else:
                    return 'ERROR'
            
            if expr[i] in ['d','D']:
                if (expr[i+1] in ['i','I']) and listi[2]==0 and listi[3]==0:
                    listi[2]=1
                    check[i]=1
                    check[i+1]=1
                else:
                    return 'ERROR'
            if expr[i]=='[':
                count1+=1
                check[i]=1
            if expr[i]==']':
                count2+=1
                check[i]=1
            if expr[i] in string.lowercase:
                check[i]=1
            if expr[i] in ['0','1','2','3','4','5','6','7','8','9','+','-']:
                check[i]=1
            if (expr[i] in ['X','P','I','x','p','i']) and ( expr[i-1] in ['B','S','D','b','s','d']):
                check[i]=1
            if check[i]==0:
                return 'ERROR'
            if expr[i]==' ':
                return 'ERROR'
        if count1!=count2:
            return 'ERROR'
        return 'OK'
    return 'ERROR'
print f()