#include <bits/stdc++.h>
#include <string>
using namespace std;
int zh(char c)
{
if(c == '[') return 1;
if(c == '(') return 2;
if(c == ']') return 3;
if(c == ')') return 4;
return 0;
}
const int N = 10010;
int main()
{
string s;
cin >> s;
char stk[N];
int tt = 0;
bool flag = true;
for(int i = 0;i < s.size() ;i++)
{
int id = zh(s[i]);
if(id==1||id==2)
{
stk[++tt] = s[i];
}
else if(id == 3||id == 4)
{
if(tt == 0)
{
flag = false;
break;
}
char top = stk[tt];
int top_id = zh(top);
if ((top_id == 1 && id == 3) || (top_id == 2 && id == 4))
{
tt--;
}
else
{
flag = false;
break;
}
}
}
if (tt != 0) flag = false;
cout << (flag ? "true" : "false") << endl;
return 0;
}
// 64 位输出请用 printf("%lld")