using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
public static void Main() {
Console.WriteLine(BracketMatchingDepth(Console.ReadLine()));
}
public static int BracketMatchingDepth(string input) {
//解法,左括号入栈,右括号出栈,并在出栈的时候统计栈的大小,取最大值为最大深度
Stack<char> stack = new Stack<char>();
int maxDepth = 0;
for(int i =0; i< input.Length;i++)
{
char currChar = input[i];
if(currChar == '(')
{
stack.Push('(');
}
else
{
maxDepth = Math.Max(maxDepth, stack.Count);
stack.Pop();
}
}
return maxDepth;
}
}