#include <bits/stdc++.h>//简单的栈应用
using namespace std;
int main()
{
    string s;
    cin>>s;
    stack<char>stk;
    for(int i = 0;i < s.length();i++)
    {
        if(s[i]=='('||s[i]=='['){
            stk.push(s[i]);
        }
        if(s[i]==')')
        {
            if(stk.empty()){//先检查是否为空
                cout<<"false";
                return 0;
            }
            else {
                if(stk.top()=='('){
                    stk.pop();
                }
                else {
                    cout<<"false";
                    return 0;
                }
            }
        }
        if(s[i]==']'){
            if(stk.empty()){
                cout<<"false";
                return 0;
            }
            else {
                    if(stk.top()=='['){
                        stk.pop();
                    }
                    else {
                        cout<<"false";
                        return 0;
                    }
            }
        }
    }
        cout<<"true";
    return 0;
}