process.stdin.resume();
process.stdin.setEncoding('utf8');
function isBalanced(s)
{
var open = (arguments.length > 1) ? arguments[1] : '(';
var close = (arguments.length > 2) ? arguments[2] : ')';
var c = 0;
for(var i = 0; i < s.length; i++)
{
var ch = s.charAt(i);
if ( ch == open )
{
c++;
}
else if ( ch == close )
{
c--;
if ( c < 0 ) return false;
}
}
return c == 0;
}
process.stdin.on('data', function (chunk) {
var lines = chunk.toString().split('\n');
lines.forEach(function(line) {
var result = isBalanced(line);
process.stdout.write(result + '\n');
});
});
cHJvY2Vzcy5zdGRpbi5yZXN1bWUoKTsKcHJvY2Vzcy5zdGRpbi5zZXRFbmNvZGluZygndXRmOCcpOwoKZnVuY3Rpb24gaXNCYWxhbmNlZChzKQp7CiAgdmFyIG9wZW4gPSAoYXJndW1lbnRzLmxlbmd0aCA+IDEpID8gYXJndW1lbnRzWzFdIDogJygnOwogIHZhciBjbG9zZSA9IChhcmd1bWVudHMubGVuZ3RoID4gMikgPyBhcmd1bWVudHNbMl0gOiAnKSc7ICAKICB2YXIgYyA9IDA7CiAgZm9yKHZhciBpID0gMDsgaSA8IHMubGVuZ3RoOyBpKyspCiAgewogICAgdmFyIGNoID0gcy5jaGFyQXQoaSk7CiAgICBpZiAoIGNoID09IG9wZW4gKQogICAgewogICAgICBjKys7CiAgICB9CiAgICBlbHNlIGlmICggY2ggPT0gY2xvc2UgKQogICAgewogICAgICBjLS07CiAgICAgIGlmICggYyA8IDAgKSByZXR1cm4gZmFsc2U7CiAgICB9CiAgfQogIHJldHVybiBjID09IDA7Cn0KCnByb2Nlc3Muc3RkaW4ub24oJ2RhdGEnLCBmdW5jdGlvbiAoY2h1bmspIHsKCXZhciBsaW5lcyA9IGNodW5rLnRvU3RyaW5nKCkuc3BsaXQoJ1xuJyk7CglsaW5lcy5mb3JFYWNoKGZ1bmN0aW9uKGxpbmUpIHsKCQl2YXIgcmVzdWx0ID0gaXNCYWxhbmNlZChsaW5lKTsKCQlwcm9jZXNzLnN0ZG91dC53cml0ZShyZXN1bHQgKyAnXG4nKTsKCX0pOwp9KTs=