Balanced Paranthesis

4

1 votes
Easy
Problem

You are given a string composed of the following characters '(', ')', '{', '}', '[', ']'. You are allowed to swap characters of the string any number of times. Find whether it is possible to construct a balanced sequence of paranthesis.

"Swapping chararacters of string", means if there are 2 indexes i and j then after the swap operation, character at index i will be the character which was previously at index j, and character at index j will be the character which was previously at index i.

"()()" is balanced.

")(" is not balanced.

INPUT

The first and only line of input contains a string s (1 ≤ |s| ≤ 106) — a string composed of '(', ')', '{', '}', '[', ']'

OUTPUT

The only line of output contains a string ("YES" or "NO") — whether it is possible to construct a sequence of balanced parenthesis by swapping characters of string any number of times.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?