Checking the balance of parentheses in a string

C# Medium strings

Task «Checking the balance of parentheses in a string»

Given a string containing the characters '(' and ')', as well as other characters. It is necessary to check whether the sequence of parentheses is balanced. Parentheses are considered balanced if each opening parenthesis has a corresponding closing parenthesis in the correct order, and there are no extra closing parentheses. Other characters are ignored. The length of the string does not exceed 1000 characters.

Input Format

One line containing arbitrary characters.

Output Format

Output 'YES' if the brackets are balanced, and 'NO' otherwise.

Examples

Example 1

INPUT
(())()
OUTPUT
YES

Example 2

INPUT
(())
OUTPUT
YES
main.cs