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. 
/* Author: Ronak Agarwal, reader part not written by me*/
import java.io.* ; import java.util.* ;
import static java.lang.Math.min ; import static java.lang.Math.max ;
import static java.lang.Math.abs ; import static java.lang.Math.log ;
import static java.lang.Math.pow ; import static java.lang.Math.sqrt ;
/* Thread is created here to increase the stack size of the java code so that recursive dfs can be performed */
public class Contest{
	public static void main(String[] args) throws IOException{
		new Thread(null,new Runnable(){	public void run(){ exec_Code() ;} },"Solver",1l<<27).start() ;
	}
	static void exec_Code(){
		try{
			Solver Machine = new Solver() ;
			Machine.Solve() ; Machine.Finish() ;}
		catch(Exception e){ e.printStackTrace() ; print_and_exit() ;}
		catch(Error e){ e.printStackTrace() ; print_and_exit() ; }
	}
	static void print_and_exit(){ System.out.flush() ; System.exit(-1) ;}
}
/* Implementation of the Reader class */
class Reader { 
	private InputStream mIs;
	private byte[] buf = new byte[1024];
	private int curChar,numChars;
	public Reader() { this(System.in); } 
	public Reader(InputStream is) { mIs = is;} 
	public int read() {
		if (numChars == -1) throw new InputMismatchException();    
		if (curChar >= numChars) {
			curChar = 0;
			try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}
			if (numChars <= 0) return -1;            
		}
		return buf[curChar++];
	} 
	public String nextLine(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString() ;
	} 
	public String s(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		}while (!isSpaceChar(c));
		return res.toString();
	} 
	public long l(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		int sgn = 1;
		if (c == '-') { sgn = -1 ; c = read() ; }
		long res = 0;
		do{
			if (c < '0' || c > '9') throw new InputMismatchException();
			res *= 10 ; res += c - '0' ; c = read();
		}while(!isSpaceChar(c));
		return res * sgn;
	} 
	public int i(){
		int c = read() ;
		while (isSpaceChar(c)) c = read();        
		int sgn = 1;
		if (c == '-') { sgn = -1 ; c = read() ; }
		int res = 0;
		do{
			if (c < '0' || c > '9') throw new InputMismatchException();
			res *= 10 ; res += c - '0' ; c = read() ;
		}while(!isSpaceChar(c));
		return res * sgn;
	} 
	public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
	public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
}   
/* All the useful functions,constants,renamings are here*/
class Template{
	/* Constants Section */
	final int INT_MIN = Integer.MIN_VALUE ; final int INT_MAX = Integer.MAX_VALUE ;
	final long LONG_MIN = Long.MIN_VALUE ; final long LONG_MAX = Long.MAX_VALUE ;
	static long MOD = 1000000007 ;
	static Reader ip = new Reader() ;	
	static PrintWriter op = new PrintWriter(System.out) ;
	/* Methods for writing */
	static void p(Object o){ op.print(o) ; }
	static void pln(Object o){ op.println(o) ;}
	static void Finish(){ op.flush(); op.close(); }
	/* Implementation of operations modulo MOD */
	static long inv(long a){ return powM(a,MOD-2) ; }
	static long m(long a,long b){ return (a*b)%MOD ; }
	static long d(long a,long b){ return (a*inv(b))%MOD ; }
	static long powM(long a,long b){
		if(b<0) return powM(inv(a),-b) ;
		long ans=1 ;
		for( ; b!=0 ; a=(a*a)%MOD , b/=2) if((b&1)==1) ans = (ans*a)%MOD ;
		return ans ;
	}
	/* Renaming of some generic utility classes */
	final static class mylist extends ArrayList<pair>{}
	final static class myset extends TreeSet<Integer>{}
	final static class mystack extends Stack<Integer>{}
	final static class mymap extends TreeMap<Integer,Integer>{}
}
/* Implementation of the pair class, useful for every other problem */
class pair implements Comparable<pair>{
	int x ; long y ;
	pair(int _x,long _y){ x=_x ; y=_y ;} 
	public int compareTo(pair p){
		return (this.x<p.x ? -1 : (this.x>p.x ? 1 : (this.y<p.y ? -1 : (this.y>p.y ? 1 : 0)))) ;
	}
}
/* Main code starts here */
class Solver extends Template{
	class Node{
		int num ;
		Node lf,rg ;
		Node(int _num){ num = _num ;}
		Node(){num=-1 ;}
		long mx[],mn[] ;
	}
	char mode = 'P' ;
	int n ;
	void solve_Node(Node nd){
		if(nd.num!=-1){
			long mx[] = new long[1] ; long mn[] = new long[1] ;
			mx[0]=nd.num ; mn[0] = nd.num ;
			nd.mx = mx ; nd.mn = mn ;
			return ;
		}
		solve_Node(nd.lf) ; solve_Node(nd.rg) ;
		Node lf = nd.lf ; Node rg = nd.rg ;
		int pad = mode=='P' ? 1 : 0 ;
		int mxl = min(lf.mx.length+max(rg.mx.length+pad,rg.mn.length+1-pad),n) ;
		int mnl = min(lf.mn.length+max(rg.mx.length+1-pad,rg.mn.length+pad)-1,n) ;
		long mx[] = new long[mxl+1] ;
		long mn[] = new long[mnl+1] ;
		Arrays.fill(mx,INT_MIN) ; Arrays.fill(mn,INT_MAX) ;
		/*Case+ */{
			int ll = lf.mx.length ; int lr = rg.mx.length ;
			int add = pad ;
			for(int i=0 ; i<ll ; i++){
				for(int j=0 ; j<lr ; j++){
					int itr = i+j+add ;
					if(itr>n) break ;
					mx[itr] = max(mx[itr],lf.mx[i]+rg.mx[j]) ;
				}
			}
			ll = lf.mn.length ; lr = rg.mn.length ;
			for(int i=0 ; i<ll ; i++){
				for(int j=0 ; j<lr ; j++){
					int itr = i+j+add ;
					if(itr>n) break ;
					mn[itr] = min(mn[itr],lf.mn[i]+rg.mn[j]) ;
				}
			}
		}
		/*Case- */{
			int ll = lf.mx.length ; int lr = rg.mn.length ;
			int add = 1-pad ;
			for(int i=0 ; i<ll ; i++){
				for(int j=0 ; j<lr ; j++){
					int itr = i+j+add ;
					if(itr>n) break ;
					mx[itr] = max(mx[itr],lf.mx[i]-rg.mn[j]) ;
				}
			}
			ll = lf.mn.length ; lr = rg.mx.length ;
			for(int i=0 ; i<ll ; i++){
				for(int j=0 ; j<lr ; j++){
					int itr = i+j+add ;
					if(itr>n) break ;
					mn[itr] = min(mn[itr],lf.mn[i]-rg.mx[j]) ;
				}
			}
		}
		nd.mx = mx ; nd.mn = mn ;
	}
	char c[] ;
	int idx=1 ;
	Node get_root(){
		if(c[idx]!='(' && c[idx]!=')' && c[idx]!='?') return new Node(c[idx++]-'0') ;
		Node nd = new Node() ; idx++ ;
		nd.lf = get_root() ;   idx++ ;
		nd.rg = get_root() ;   idx++ ;
		return nd ;
	}
	int P,M ;
	public void Solve() throws IOException{
		c = ("1"+ip.s()).toCharArray() ;
		Node rt = get_root() ;
		P = ip.i() ; M = ip.i() ;
		n = min(P,M) ;
		if(M<P) mode = 'M' ;
		solve_Node(rt) ;
		pln(rt.mx[n]) ;
	}
} 