#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
int main(){
string ans="true",str;
char couple;
cin>>str;
stack<char>s;
for(int i=0;i<str.size();i++)
if (str[i]=='('||str[i]=='['||str[i]=='{')s.push(str[i]);
else if(str[i]==')'||str[i]==']'||str[i]=='}'){
if (str[i]==')')couple='(';
else if(str[i]==']')couple='[';
else couple='{';
if(s.empty()||s.top()!=couple){
ans="false";
break;
}else s.pop();
}
if(!s.empty())ans="false";
cout<<ans<<endl;
return 0;
}