program sec; var row,srow:string; i,bl,br:byte; error,bx,bp,si,di:boolean; begin while not eof do begin readln(row); error := false; for i:=1 to length(row) do if not((pos(row[i],'+-[]BDIPSX')>0) or (row[i] in ['a'..'z']) or (row[i] in ['0'..'9'])) then error := true; if (pos('bx',row)>0) or (pos('bX',row)>0) or (pos('Bx',row)>0) or (pos('BX',row)>0) then bx:=true else bx:=false; if (pos('bp',row)>0) or (pos('bP',row)>0) or (pos('Bp',row)>0) or (pos('BP',row)>0) then bp:=true else bp:=false; if (pos('si',row)>0) or (pos('sI',row)>0) or (pos('Si',row)>0) or (pos('SI',row)>0) then si:=true else si:=false; if (pos('di',row)>0) or (pos('dI',row)>0) or (pos('Di',row)>0) or (pos('dI',row)>0) then di:=true else di:=false; if (bx and bp) or (si and di) then error := true; if (row[1] = '-') or (row[length(row)] = '-') or (row[1] = '+') or (row[length(row)] = '+') then error := true; bl := 0; br := 0; for i:=1 to length(row) do begin if row[i] = '[' then inc(bl); if row[i] = ']' then inc(br); end; if not error then if br<>bl then error := true; if not error then for i:=2 to length(row)-1 do begin if row[i] = '-' then if (row[i+1] = ']') or (row[i-1] = '[') then error := true; if row[i] = '+' then if (row[i+1] = ']') or (row[i-1] = '[') then error := true; end; if error then writeln('ERROR') else writeln('OK'); end; end.