#include<bits/stdc++.h>
#define ROW 6
#define COLUMN 9
using namespace std;
string table[ROW][COLUMN]= {
{"","(",")","*","+","-","/","i","#"},
{"E","Te","","","","","","Te",""},
{"e","","ε","","+Te","-Te","","","ε"},
{"T","Ft","","","","","","Ft",""},
{"t","","ε","*Ft","ε","ε","/Ft","","ε"},
{"F","(E)","","","","","","i",""}
};
string Get_table(string x,string a) {
string ans="";
for(int i=0; i<ROW; i++) {
for(int j=0; j<COLUMN; j++) {
if(x==table[i][0]&&a==table[0][j]) {
ans=table[i][j];
return ans;
}
}
}
return ans;
}
bool check_LL1(string input) {
bool flag=true;
stack < string > s;
s.push("#");
s.push("E");
int i=0;
string a=input.substr(i,1);
string x;
while(flag) {
string RS;
x=s.top();
if(x==a && a=="#") {
break;
} else if(x==a && a!="#") {
s.pop();
i++;
a=input.substr(i,1);
} else if((RS=Get_table(x,a))!="") {
if(RS!="ε") {
s.pop();
for(int j=RS.length()-1; j>=0; j--) {
string tmp=RS.substr(j,1);
s.push(tmp);
}
} else {
s.pop();
}
} else {
flag=false;
break;
}
}
return flag;
}
int main() {
string input;
while(cin>>input) {
input=input+"#";
if(check_LL1(input)) {
cout<<"syntax correct"<<endl;
} else {
cout<<"syntax error"<<endl;
}
}
return 0;
}