#include<bits/stdc++.h>
using namespace std;
bool isbalanced(string exp)
{
    stack<char>st;
    for( char ch:exp)
    {
        if(ch=='{'||ch=='['||ch=='(')
        {
        st.push(ch);
        
        }
        else if(ch=='}'||ch==']'||ch==')')
        {
            if (st.empty())
                return false;
                char top=st.top();
                st.pop();
                if(ch==')'&& top!='(')
                return false;
                else if(ch=='}'&& top!='{')
                return false;
                else if(ch==']'&& top!='[')
                return false;
                
            
        }
    }
    return st.empty();
}
int main()
{
    string exp;
    getline(cin,exp);
    if(isbalanced(exp))
    {
    cout<"true"<<endl;
    }
    else{
    cout<<"false<<endl";
    }
    
    return 0;
}