import java.util.*;
public class Parenthesis {
public static boolean chkParenthesis(String A, int n) {
int l=0;
for(int i=0;i<A.length();i++){
char ch=A.charAt(i);
if(ch=='('){
l++;
}else if(ch==')'){
if(l>0){
l--;
}else{
return false;
}
}else{
return false;
}
}
return l==0;
}
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
int n=sc.nextInt();
boolean ret=chkParenthesis(str,n);
System.out.println(ret);
}
}