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

int main() {
    string str;
    cin >> str;
    stack<char> ms;
    int xz = 0, xy = 0, zz = 0, zy = 0;
    for (int i = 0; i < str.length(); i++) {
        switch (str[i]) {
            case '(':
                ms.push(str[i]);
                break;
            case ')':
                //栈空的话直接错
                if((!ms.empty())&&(ms.top() == '(')){
                    ms.pop();
                } else {
                    cout << "false" << endl;
                    return 0;
                }
                break;
            case '[':
                ms.push(str[i]);
                break;
            case ']':
                //栈空的话直接错
                if((!ms.empty())&& (ms.top() == '[')) {
                    ms.pop();
                } else {
                    cout << "false" << endl;
                    return 0;
                }
                break;
            default:
                break;
        }
    }

    if (ms.empty()) {
        cout << "true" << endl;
    } else {
        cout << "false" << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")