#include<map>
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;
class Solution{
public:
bool isValid(string s){
cout<<s.length();
if (sizeof(s)<=1||(s.length())%2!=0) return false;
map<char,char>wordbook;
wordbook[']']='[';
wordbook['}']='{';
wordbook[')']='(';
stack<char>mystack;
for(int i=0;i<s.length();i++){
if (s[i]=='{'|| s[i]=='(' ||s[i]=='[')
mystack.push(s[i]);
else if(s[i]=='}'||s[i]==')'||s[i]==']'){
if(mystack.empty()) return false;
else if (wordbook[s[i]]==mystack.top()){
mystack.pop();
continue;
}
}
else return false;
}
if (mystack.empty()) return true;
else return false;}
};
int main(){
Solution s;
string m="(])";
bool ans=s.isValid(m);
cout<<ans;
return 0;
}