#include<bits/stdc++.h>
#include <iostream>
using namespace std;
string S,s;stack<char>t;
int main(){
    cin>>S;
    for (int i=0; i<(S.size());++i) {
    if (S[i]=='['||S[i]==']'||S[i]=='('||S[i]==')') {
    s.push_back(S[i]);
    }
    }
    for (char c:s) {
    if (c=='('||c=='[') {
    t.push(c);
    }else{
    if (t.empty()) {
    cout<<"false";return 0;
    }else {
    if (c==')'&&t.top()=='(') {
    t.pop();
    }else if (c==']'&&t.top()=='[') {
    t.pop();
    }else {
    cout<<"false";return 0;
    }
    }
    }
    }
    if (t.empty()) {
    cout<<"true";
    }else {
    cout<<"false";
    }
    return 0;
}