Ancient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as Ahmes arithmetic expression.

An Ahmes arithmetic expression can be defined as: 

  * "d" is an Ahmes arithmetic expression, where d is a one-digit positive integer; 
  * "(E1 op E2)" is an Ahmes arithmetic expression, where E1 and E2 are valid Ahmes arithmetic expressions (without spaces) and op is either plus ( + ) or minus ( - ). 

For example 5, (1-1) and ((1+(2-3))-5) are valid Ahmes arithmetic expressions.

On his trip to Egypt, Fafa found a piece of papyrus paper having one of these Ahmes arithmetic expressions written on it. Being very ancient, the papyrus piece was very worn out. As a result, all the operators were erased, keeping only the numbers and the brackets. Since Fafa loves mathematics, he decided to challenge himself with the following task:

Given the number of plus and minus operators in the original expression, find out the maximum possible value for the expression on the papyrus paper after putting the plus and minus operators in the place of the original erased operators.

Input

The first line contains a string E (1 ≤ |E| ≤ 104) — a valid Ahmes arithmetic expression. All operators are erased and replaced with '?'.

The second line contains two space-separated integers P and M (0 ≤ min(P, M) ≤ 100) — the number of plus and minus operators, respectively. 

It is guaranteed that P + M =  the number of erased operators.

Output

Print one line containing the answer to the problem.

Examples

Input

(1?1)
1 0


Output

2


Input

(2?(1?2))
1 1


Output

1


Input

((1?(5?7))?((6?2)?7))
3 2


Output

18


Input

((1?(5?7))?((6?2)?7))
2 3


Output

16

Note

  * The first sample will be (1 + 1) = 2. 
  * The second sample will be (2 + (1 - 2)) = 1. 
  * The third sample will be ((1 - (5 - 7)) + ((6 + 2) + 7)) = 18. 
  * The fourth sample will be ((1 + (5 + 7)) - ((6 - 2) - 7)) = 16. 
import java.util.*;
 
//http://codeforces.com/contest/935/problem/E
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
 
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC.main();
	}
}
 
class TaskC {
  public static void main() {
  
    Scanner sc = new Scanner(System.in);
    
    String line = sc.nextLine();
    int p = sc.nextInt();
    int m = sc.nextInt();
    
    boolean lessPlusses = p <= m;
    
    int nodeID = -1;
    
    int[][] max = new int[10010][104];
    int[][] min = new int[10010][104];
    int[] subcounts = new int[10001];
    
    Stack<TreeNode> stack = new Stack<TreeNode>();
    int root = -1000000;
    for(char x : line.toCharArray()) {
      
      if(x >= '1' && x <= '9') {
        nodeID++;
        if (nodeID > root){
          root = nodeID;
        }
        stack.push(new TreeNode(x, null, null, nodeID));
        max[nodeID][0] = x - '0';
        min[nodeID][0] = x - '0';
       
        subcounts[nodeID] = 0;
        
        
      }
      else if(x == ')'){
        
        nodeID++;
        if (nodeID > root){
          root = nodeID;
        }
        TreeNode b = stack.pop();
        TreeNode a = stack.pop();
        
        stack.push(new TreeNode('?', b, a, nodeID));
        /*max[nodeID][0] = 0;
        min[nodeID][0] = 0;*/
        subcounts[nodeID] = 1 + subcounts[a.id] + subcounts[b.id];
        int cap = Math.min(100, subcounts[nodeID]);
        if (subcounts[nodeID] == 1){ // if the node connects two numbers
          
          if (lessPlusses){
            if (p > 0){
              max[nodeID][1] = max[a.id][0]+max[b.id][0];
              min[nodeID][1] = max[a.id][0]+max[b.id][0];
              // doesn't matter whether we put max/min b/c they have same values
            }
            if (m > 0){
              max[nodeID][0] = max[a.id][0]-max[b.id][0];
              min[nodeID][0] = max[a.id][0]-max[b.id][0];
            }
            //System.out.println(max[a.id][0]+" "+max[b.id][0]);
          }else{
            if (m > 0){
              max[nodeID][1] = max[a.id][0]-max[b.id][0];
              min[nodeID][1] = max[a.id][0]-max[b.id][0];
              // doesn't matter whether we put max/min b/c they have same values
            }
            if (p > 0){
              max[nodeID][0] = max[a.id][0]+max[b.id][0];
              min[nodeID][0] = max[a.id][0]+max[b.id][0];
            }
          }
            
        }else{
          for (int i=0; i<=cap; i++){
            max[nodeID][i] = -10000000;
            min[nodeID][i] = 10000000;
          }
          for(int i = 0; i <= cap; i++) {
            
            
            //j is the number of operators of the other type
            int j = subcounts[nodeID] - i;
            
      
            
            //i is number of pluses left, j the minuses
            if(lessPlusses) {
             
              // iterate through all possible amounts of plusses on each side
              if (i > p){
                continue;
              }
              
              for (int k=0; k<=i; k++){
                int minusesL = subcounts[a.id]-k;
                int minusesR = subcounts[b.id]-(i-k);
                //System.out.println(minusesL+" "+minusesR);
                if (minusesL < 0 || minusesR < 0){
                  continue;
                }
          
                
                if (k+(i-k) > p || minusesL+minusesR > m){
                  continue;
                }
                /*if (nodeID == 4){
                  System.out.println(k+" "+(i-k));
                  System.out.println(minusesL+" "+minusesR);
                  System.out.println();
                }*/
                
                  if (k+(i-k)+1 <= p){
                    max[nodeID][i+1] = Math.max(max[nodeID][i+1], max[a.id][k]+max[b.id][i-k]);
                    
                    min[nodeID][i+1] = Math.min(min[nodeID][i+1], min[a.id][k]+min[b.id][i-k]);
                  }
                  
                  /*if (nodeID == 4){
                      System.out.println(max[nodeID][1]);
                    }*/
                
                
                  if (minusesL+minusesR+1 <= m){
                  
                     max[nodeID][i] = Math.max(max[nodeID][i], max[a.id][k]-min[b.id][i-k]);
                     
                     min[nodeID][i] = Math.min(min[nodeID][i], min[a.id][k]-max[b.id][i-k]);
                  }
                /*if (nodeID == 4){
                      System.out.println(max[nodeID][1]);
                    }*/
                
              }
              
            }else{
              // now the array is [vertex][# minuses]
              
              // iterate through all possible amounts of plusses on each side
              if (i > m){
                continue;
              }
              
              for (int k=0; k<=i; k++){
                int plusesL = subcounts[a.id]-k;
                int plusesR = subcounts[b.id]-(i-k);
                
                if (plusesL < 0 || plusesR < 0){
                  continue;
                }
          
                
                if (k+(i-k) > m || plusesL+plusesR > p){
                  continue;
                }
                /*if (nodeID == 4){
                      System.out.println(k+" "+(i-k));
                      System.out.println(plusesL+" "+plusesR);
                      System.out.println();
                }*/
                
                  if (plusesL+plusesR+1 <= p){
                    
                    max[nodeID][i] = Math.max(max[nodeID][i], max[a.id][k]+max[b.id][i-k]);
                    min[nodeID][i] = Math.min(min[nodeID][i], min[a.id][k]+min[b.id][i-k]);
                  }  
                  
                
             
                
                  if (k+(i-k)+1 <= m){ // +1 to the sum of minuses because we're adding another -
                     max[nodeID][i+1] = Math.max(max[nodeID][i+1], max[a.id][k]-min[b.id][i-k]);
                     min[nodeID][i+1] = Math.min(min[nodeID][i+1], min[a.id][k]-max[b.id][i-k]);
                  }
                  
                
              }
            }
          }
        }
        //i is the number of operators we are selecting that are capped at 100
       
        
        
      }
    }
    if (lessPlusses){
      System.out.println(max[root][p]);
    }else{
      System.out.println(max[root][m]);
    }
  }
}
 
class TreeNode {
  
  TreeNode left;
  TreeNode right;
  char value;
  int id;
  
  public TreeNode(char c, TreeNode l, TreeNode r, int i) {
    left = l;
    right = r;
    value = c;
    id = i;
  }
  
  
}
class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
 
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }
 
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
 
    public int nextInt() {
        return Integer.parseInt(next());
    }
 
    }
