import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] arrC = sc.next().toCharArray(); Stack<Character> sk = new Stack<>(); for (int i = 0; i < arrC.length; i++) { if (arrC[i] == ')') { int tempX = 0; int maxX = 0; char c = sk.pop(); while (c != '(') { if (c == '|') { maxX = Math.max(tempX, maxX); tempX = 0; } else if(c == 'x') { tempX++; } c = sk.pop(); } maxX = Math.max(tempX, maxX); for (int j = 0; j < maxX; j++) { sk.add('x'); } } else { sk.add(arrC[i]); } } String str = ""; while (!sk.isEmpty()) { char c = sk.pop(); if (c == 'x' || c == '|') str += c; } String[] s = str.split("\\|"); int num = 0; for (int i = 0; i < s.length; i++) { num = Math.max(num, s[i].length()); } System.out.println(num); } }