//大神帮忙优化
#include <bits/stdc++.h>
using namespace std;
int main() {
stack<int> st;
string str;
cin >> str;
int flag = 1;
if (str.empty()) {
cout << "true";
} else {
for (int i = 0; i < str.length(); i++) {
if (str[i] == '(' || str[i] == '[') {
st.push(str[i]);
} else if (str[i] == ')') {
if (st.empty() || st.top() == '[') {
cout << "false";
flag = 0;
break;
} else {
st.pop();
}
} else if (str[i] == ']') {
if (st.empty() || st.top() == '(') {
cout << "false";
flag = 0;
break;
} else {
st.pop();
}
}
}
}
if (flag == 1) {
if(st.empty())
{
cout<<"true";
}
else {
cout<<"false";
}
}
}
// 64 位输出请用 printf("%lld")