#(#(#((##((()))(((#)(#()#(((()()(()#(##(((()(((()))#(((((()(((((((()#((#((()(#(((()(()##(()(((()((#(
 (#((((()
 (#((
 ((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((##
 (())((((#)
 (#(
 (#))(#(#)((((#(##((#(#((((#(##((((((#((()(()(())((()#((((#((()((((#(((((#(##)(##()((((()())(((((#(((
 ##((((((()
 #((#
 #))))
 (((((#(#(#(#()
 ((#(()#(##
 (((((((((((((((((((###################
 )((##((###
 (((()#(#)(
 ((#)(
 )(((())#
 ()((#((#(#()
 ((#(
 ()#(#())()()#)(#)()##)#((()#)((#)()#())((#((((((((#)()()(()()(((((#)#(#((((#((##()(##(((#(()(#((#))#

-1
 -1
 -1
 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
 3
 -1
 -1
 -1
 -1
 -1
 1
1
1
5
 1
1
1
1
 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
 -1
 -1
 -1
 -1
 1
1
3
 -1
 -1


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;

public class Main {

    public static ArrayList<Integer> list = new ArrayList<Integer>();
    public static ArrayList<Integer> list2 = new ArrayList<Integer>();
    //public static ArrayList<Integer> list2= new ArrayList<Integer>();
    public static Scanner input = new Scanner(System.in);

    public static void main(String[] args)
            throws IOException {

        // BufferedReader buffer=new BufferedReader(new InputStreamReader(System.in));
        //  String str;
//         while((str=buffer.readLine())!=null){
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
//while(input.hasNextLine()){
  String n=input.next();
  int open=0;
  int close=0;
  for(int i=0;i<n.length();i++){
      if(n.charAt(i)=='(')
          open++;
      else
          close++;
  }
        if(close>open || n.startsWith(")") || n.startsWith("#") ||  n.endsWith("(") ||!n.contains("#")){
            System.out.println("-1");
            return;
        }
        
      char []c=n.toCharArray();
      int x=0;
       int z=0;
      for(int i=c.length-1;i>=0;i--){
          if(c[i]==')')
              x++;
          if(c[i]=='(')
              x--;
         if(c[i]=='*')
             continue;
          if(c[i]=='#'){
               z=0;
              for(int ii=i-1;ii>=0;ii--){
                  
                  if(c[ii]=='#' || c[ii]=='*' ||c[ii]==')' )
                   {break;}
               
              
               if(c[ii]=='(')
                   {z++;c[ii]='*';continue;}
            
              
          }
              System.out.println(Math.abs(z-x));
              x=0;
          }
          
      
      }
       
        writer.flush();

    }

}
