Simple Bracket CheckerEasy

Simple Bracket Checker

EasyPractice library · +10 XPstackbracket matchingbeginner

Given a string consisting only of opening and closing brackets '(' and ')', determine if the brackets are properly matched. A string of brackets is considered properly matched if:

  1. For every opening bracket '(', there is a corresponding closing bracket ')'.
  2. The brackets are closed in the correct order. For example, '(()())' is valid, but ')(' and '())(' are not.

Print "YES" if the string is properly matched, and "NO" otherwise.

Input

A single line containing a string of '(' and ')'.

Output

Print "YES" or "NO".

Constraints

The input string contains between 1 and 1000 characters, inclusive.

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
(()())
Output
YES

All brackets are properly matched.

Example 2

Input
())
Output
NO

The second closing bracket has no matching opening bracket.

Hints