using System.Collections.Generic;
public static void Main()
string str = "))))))(())";
Stack<Char> stack = new Stack<Char>();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.Length; i++)
if (stack.Count != 0 && stack.Peek() == '(')
sb = sb.Append(stack.Pop());
Console.WriteLine(sb.ToString());
Console.WriteLine(result);