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

stack<char> st;
int main() {
    string str;
    bool result{true};
    cin >> str;
    for(int i=0;i<str.size();i++)
    {
        if (str[i] == '(' || str[i] == '[')
        {
            st.push(str[i]);
        }
        else if(str[i] == ')')
        {
            if(st.empty())
            {
                result = false;
                break;
            }
            else 
            {
                if(st.top() == '(')
                {
                    st.pop();
                }
                else
                {
                    result = false;
                    break;
                }
            }
            
        }
        else if(str[i] == ']')
        {
            if(st.empty())
            {
                result = false;
                break;
            }
            else 
            {
                if(st.top() == '[')
                {
                    st.pop();
                }
                else
                {
                    result = false;
                    break;
                }
            }
        }
    }

    cout << boolalpha <<result;
    return 0;
}
// 64 位输出请用 printf("%lld")