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

京公网安备 11010502036488号