public static void main(String[] args){
		
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		int n = in.nextInt();
		allowed = n+s.length();
		if(n >= s.length()){
			System.out.println((n+s.length())%2==0?(n+s.length()):(n+s.length()-1));
		} else {
			for(int i=0;i<allowed;i++){
				for(int j=i+1;j<allowed;j++){
					tryDo(s, i, j);
				}
			}
			System.out.println(max);
		}
	}