#include<iostream> 
#include<stack>
using namespace std;

bool test(char a, char b){
    if(a=='('&&b==')')return true;
    if(a=='['&&b==']')return true;
    return false;
}

int main(){
    stack<char>st;
	string s;
    cin>>s;
    for(auto c:s){
        if(c=='('||c=='['){
            st.push(c);
        }
        else if(c==')'||c==']'){
            if(!st.empty()){
                char temp=st.top();
                if(test(temp,c))st.pop();
                else {
                    cout<<"false"<<endl;
                    return 0;
                }
            }
            else{
                cout<<"false"<<endl;
                return 0;
            }
        }
    }
    cout<<"true"<<endl;
    return 0;
}