#include <iostream>
using namespace std;
#include <stack>
#include <string>
bool ispipei(string &s){
   stack<char>a;
    for(char c:s){
        if(c!='('&&c!=')'&&c!='['&&c!=']')continue;
        if(c=='('||c=='['){
            a.push(c);
        }
        else {
            if(a.empty())return false;
            else {
                char top=a.top();
                a.pop();
                if((c==')'&&top!='(')||(c==']'&&top!='['))return false;
            }
        }
    }
    return true;
}
int main() {
   string s;
   getline(cin,s);
   if(ispipei(s))cout<<"true"<<endl;
   else cout<<"false"<<endl;
   return 0;
}
// 64 位输出请用 printf("%lld")