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.io.*;
import java.util.*;
public class Fafamaths {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
          class pair{
           int u,v;pair(int a,int b){u=a;v=b;}
           public String toString(){return u+" "+v;}
          }
          class node{
           int v,l,r;node(){v=0;}
          }
          int MAX=20000;
          int gMAX=Integer.MAX_VALUE,gMIN=Integer.MIN_VALUE;
          node node[]=new node[MAX];
          String s;int id=0,N=0;
          void build(int n){
           if(id==s.length())return;
           if(s.charAt(id)>='1'&&s.charAt(id)<='9'){
            node[n].v=s.charAt(id)-'0';
            ++id;return;
           }
           if(s.charAt(id)=='('){
            ++id;
            node[n].l=++N;build(N);
           }
           if(s.charAt(id)=='?'){
            ++id;
            node[n].r=++N;build(N);
           }
           if(s.charAt(id)==')'){
            ++id;return;
           }
          }
          ArrayList<pair> edge;
          void print(int u){
           if(node[u].v!=0)return;
           edge.add(new pair(u,node[u].l));edge.add(new pair(u,node[u].r));
           print(node[u].l);print(node[u].r);
          }
          void print(){
           edge=new ArrayList<>();print(0);
           for(int i=0;i<edge.size();i++)System.out.println(edge.get(i));
          }
          int low,sub[];boolean bdp[][];
          long dp[][][];
          void rec(int n,int l,char cl){
           if(bdp[n][l])return;
           if(node[n].v!=0){
            dp[n][l][0]=dp[n][l][1]=node[n].v;
            bdp[n][l]=true;return;
           }
//           System.out.println(l+" "+sub[n]);
           for(int i=0;i<=l&&l!=sub[n];i++){
            if((node[node[n].l].v!=0&&i!=0)||(node[node[n].r].v!=0&&l-i!=0))continue;
            rec(node[n].l,i,cl);rec(node[n].r,l-i,cl);
            long a=dp[node[n].l][i][0]+dp[node[n].r][l-i][0];
            long b=dp[node[n].l][i][0]-dp[node[n].r][l-i][1];
            long c=dp[node[n].l][i][1]+dp[node[n].r][l-i][1];
            long d=dp[node[n].l][i][1]-dp[node[n].r][l-i][0];
            if(cl=='+'){
             a=gMAX;c=gMIN;
            }else{
             b=gMAX;d=gMIN;
            }
            dp[n][l][0]=Math.min(Math.min(a,b),dp[n][l][0]);
            dp[n][l][1]=Math.max(Math.max(c,d),dp[n][l][1]);
           }
           for(int i=0;i<=l-1;i++){
            if((node[node[n].l].v!=0&&i!=0)||(node[node[n].r].v!=0&&l-i-1!=0))continue;
            rec(node[n].l,i,cl);rec(node[n].r,l-i-1,cl);
            long a=dp[node[n].l][i][0]+dp[node[n].r][l-1-i][0];
            long b=dp[node[n].l][i][0]-dp[node[n].r][l-1-i][1];
            long c=dp[node[n].l][i][1]+dp[node[n].r][l-1-i][1];
            long d=dp[node[n].l][i][1]-dp[node[n].r][l-1-i][0];
            if(cl=='+'){
             b=gMAX;d=gMIN;
            }else{
             a=gMAX;c=gMIN;
            }
            dp[n][l][0]=Math.min(Math.min(a,b),dp[n][l][0]);
            dp[n][l][1]=Math.max(Math.max(c,d),dp[n][l][1]);
           }
           bdp[n][l]=true;
          }
          int dfs(int n){
           if(node[n].v!=0)return 0;
           return sub[n]=dfs(node[n].l)+dfs(node[n].r)+1;
          }
          public void solve(int testNumber, InputReader in, PrintWriter out) {
              s=in.next().trim();
              int p=in.nextInt(),n=in.nextInt();char ch='+';
              low=Math.min(p,n);if(low==n)ch='-';
              dp=new long[MAX][low+10][2];
              for(int i=0;i<MAX;i++){
               for(int j=0;j<low+10;j++){
                dp[i][j][0]=gMAX;
                dp[i][j][1]=gMIN;
               }
              }
              bdp=new boolean[MAX][low+10];
              sub=new int[MAX];
              for(int i=0;i<MAX;i++)node[i]=new node();
              build(0);
              dfs(0);
              rec(0,low,ch);
//              print();
                out.print(dp[0][low][1]);
          }
//          int ja[][],from[],to[],c[];
//              void make(int n,int m,InputReader in){
//               ja=new int[n+1][];from=new int[m];to=new int[m];c=new int[n+1];
//               for(int i=0;i<m;i++){
//                from[i]=in.nextInt();to[i]=in.nextInt();
//                c[from[i]]++;c[to[i]]++;
//               }
//               for(int i=1;i<=n;i++){
//                ja[i]=new int[c[i]];c[i]=0;
//               }
//               for(int i=0;i<m;i++){
//                ja[from[i]][c[from[i]]++]=to[i];
//                ja[to[i]][c[to[i]]++]=from[i];
//               }
//              }
       }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}