#K33872. Valid Parentheses Checker

    ID: 25184 Type: Default 1000ms 256MiB

Valid Parentheses Checker

Valid Parentheses Checker

Given a string s consisting solely of the characters '(' and ')', determine whether the sequence of parentheses is valid.

A sequence is considered valid if every opening parenthesis '(' has a corresponding closing parenthesis ')' in the correct order. In other words, the string is valid if it can be completely reduced by removing matching pairs.

If the sequence is valid, output 1; otherwise, output 0.

The solution should operate in \(O(n)\) time complexity, where \(n\) is the length of the string.

inputFormat

The input is provided via standard input (stdin) as a single line string. The string consists of only the characters '(' and ')'.

outputFormat

Output via standard output (stdout) a single integer: 1 if the input string is a valid parentheses sequence, or 0 if it is not.

## sample
((()))
1