#include <iostream>
#include <stack>
#include <string>
bool isMatchingPair(char opening, char closing) {
if (opening == '(' && closing == ')') return true;
if (opening == '[' && closing == ']') return true;
return false;
}
bool isBalanced(const std::string& expression) {
std::stack<char> s;
for (char ch : expression) {
if (ch == '(' || ch == '[') {
s.push(ch);
} else if (ch == ')' || ch == ']') {
if (s.empty()) {
return false;
}
char top = s.top();
s.pop();
if (!isMatchingPair(top, ch)) {
return false;
}
}
}
return s.empty();
}
int main() {
std::string expression;
std::cin >> expression;
if (isBalanced(expression)) {
std::cout << "yes" << std::endl;
} else {
std::cout << "no" << std::endl;
}
return 0;
}
/**************************************************************
Problem: 1486
User: panyuchen
Language: C++
Result: Accepted
Time:31 ms
Memory:2080 kb
****************************************************************/