jtifziirovbklaioslunwvtdavraandnzcwqbealbvqonoxufqrsewwrzvkrecrfqhdduwmcdcdhdtvpyshfhgdwdkmglskidhzayvouwhumzhcphocqyfcdddhzayvouwhumzhcphocqyfcddayfakoxofjgusuonehbxbokjsdlktqrcdurogxltsysyjbiagrvhky
32
 kbxuunznjtxutlauuuipifggjjkequbpvbagmxojhgxtakxioxsmrmoatlyzwsygibhafspqnfbycyztxmtpirqcyhalluhhubne
100
 zwvrx
3
 wccknxhbqzjwaseubvizxuisnzneatgjhaatrfydssgzufyztesrxnjlbhckybqlbncvqgjcoupirpqnnmacejicjzhattqolmclqnotctcsliyvjwutvrtrhichssehtlwbrq
123
 cznjenwypyeulxzdxfhalfbyefhhgieybtzjmbdirrpybxnftpcqfhrhiifsfkllztwejdvhvtnxecnfgwwxhhcsjsqzhrjddauttbxphfzljgbvcqshateqeulxzdxfhalfbyefhhgieybtzjmbdirrpybxnftpcqfhrhiifsfkllztwejdvhvtnxecnfgwwxhhcsjs
41
 ezlrqvaeekbnkqqjcijtkaoisqpbguqfsqxtzjotdhtrnaoxutybbqzzhrqvaeekbnkqqjcijtkaoisqpbguqfsqxtzjotdhtrnaoxutybbqzzhzoeptxwaunvarfcapxsnamwjyqpxbiegizqotuqen
15
 zumtumtlitf
2
 wqlvwkiiqfmesejedhyjjfgzqfmiqyaiqefzaywrdundcmbfvhdflrpvkitbltbrzedvozltptkaanbpmjvsdnpthcepfydrdlscexczxwzyatupzlxdhnezdsipeyjqmbvoavsgeuulkqkexpwpttvxeovcjrqnzdeiaatzglvwkiiqfmesejedhyjjfgzqfmiqyaiq
141
 nemtbujbscvkgxnbqboeohzfozihjvhcllfseiouggzojhqcoqrvtdsgkubiophnhahgplhtjxblicnavkayzsydmxphgfvhlllontqfpqitrpjiadpmogtqyjhqfpqitrpjiadpmogtqyjhvaopbzglvdmwzsrhtsszyengbihrrzljvofgugmjedgujhzvlebpprue
140
 skllmtqzajnzjkuflkazjku
10
 ngkdgsdxouojadjqzgxewuuyxdlxulgrblxpkyzhgmkeatmhvbdelmxxrqtsarfvotcxfuiqsxbnczbadelhxtlfwrnbisayeveiejvycllhkictyyriqseznziyurlgiejvycllhkictyyriqseznziyurlgwiubyvqfmabhstqalicamyholkqlvtjfhcfbyr
133
 uzfvkgoaimitrlfjn
43
 ijtvifbuajod
5
 cxpleheyfwu
132
 lfydqwrwevvvclkkainwxwvqf
33
 kitxizqtbzwjqldmhwpmznaoddtgqzithwvyeyuixxhlnmksmsysikftzrskbnriebbwzermgcxalwpmznaoddtgqzithwvyeyuixxhlnmksmsy
32
 uqytussdzppiuwxterrfyrwtsrkdpfzhjpeuuulopnnjtltdtlkzwixouxteuheqaxhaicoeveggwkcnkamluxykyktmvafajfnxmeuuulopnnjtltdtlkzwixouxteuheqaxhaicoeveggwkcnkamluxykyktmvafajfnxmefkurbbcbesiwcauwmlhmfslcavsreea
41
 xaxgnvphqavbuxzkcsptsih
150
 zonkpassuptcnpeoogztfpaspwdwnmiwsxeskfajlpfswzrdcxhlzxrgddtgmnngevbiybdnwelkzonhrzgldriyymrzduulifphxypcaqurgeqitkxxnsqdpsxattjoncmhihgxdaxixkmockynyjefvhrzgldriyymrzduulifphxypcaqurgeqitkxxnsqdpsxatt
200
 ifglyzxttgfpcgvpfmfmjhuzmgmaiivnbrzjevgxosclwqfewklzstkjmnjmqgpeshndmzrtthpjbhuqoldgvkkmkqinkptatpytrchkvjyeimsfmjhuzmgmaiivnbrzjevgxosclwqfewklzstkjmnjmqgpeshndmzrtthpjbhuqoldgvkkmkqinkptatpytrchkvjy
15
 mklxokaoaxzccddmsxzc
41
 eluswgbaoqmkfymoidkripnpgmbvhydcuupfhecefgosemhverqwzxklzzacdgcrrlzdnocxmzxtiamqpxspfogqhrlsnfzdexamrkowqpqggolnrvxfhenedmfzngnavgnjkzsnkjjjfcgfqjuywmrt
115
 xbmrxbmrkzovhb
3
 ktkkckrzvjhdspjmtljrmwgfoxeuadhajkfjpcmquqldlkutwyqaupnypwqfbxbuaaywcflplmqxnvwmkzpdvvkgxkmsggxmdangeyudqrgrihgbljrmwgfoxeuadhajkfjpcmquqldlkutwyqaupnypwqfbxbuaaywcflplmqxnvwmkzpdvvkgxkmsggxmdangeyudq
57
 thdnszfpaznmjlzacpovjcvybdkynhnvkaxvncfpofvnfpkggyfvqbklvrnbwpjswbrvjvqyzheslzxvuuqpbrvjvqyzheslzxvuuqprxasesuweenacripkyevplccdlxocfuqklypxactpajkmhcsgbxwgznizwndthualdbbgxhrtdrodoiddzdmxtatssfsuksqz
23
 fonwebmlwaxthdwche
57
 pdgrwrozhkrwwgebwvuilwm
32
 jhfwjyyzwrjiyrrgveiqkoltivghgkontrqragikttxxuwszjwqhwxindyrdqhucnbwgwrppgqmsasrzohezjlfmkzsqptwpratprcrxyxecnlsaiqrvimihmhjfgzwdtvmfhgbuonpsblphyoxzclkrwbwrkasahiirzqlfjdoomlosltldbpomyyhmdwfchzxnmwlh
200
 ayi
10
 eexlzphiay
1
 auxrkguktewrcwwklhmuxkgdialidacmjinwcsrtfrtdsvqsbwuqtsrmsyizsvdkbqwrbuphqqvzktqkskylnnqbezibqnaytuuqddrigdkbqwrbuphqqvzktqkskylnnqbezi
23

64
 200
 6
 246
 220
 108
 6
 334
 280
 20
 266
 60
 10
 142
 58
 120
 134
 172
 400
 186
 60
 230
 8
 190
 46
 74
 54
 400
 12
 2
 86

//import java.awt.GradientPaint;
//import java.awt.geom.Line2D;
//import java.io.BufferedReader;
//import java.io.FileReader;
//import java.io.FileWriter;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.OutputStreamWriter;
//import java.io.PrintWriter;
//import java.math.BigInteger;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Collections;
//import java.util.HashMap;
//import java.util.HashSet;
//import java.util.LinkedList;
//import java.util.PriorityQueue;
//import java.util.Queue;
//import java.util.Scanner;
//import java.util.Stack;
//import java.util.StringTokenizer;
//
//public class a {
//	public static class node {
//		long one;
//		long two;
//
//		node(long index, long val) {
//			one = index;
//			two = val;
//
//		}
//
//	}
//
//	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		StringBuilder q = new StringBuilder();
//		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
//		int n = Integer.parseInt(in.readLine());
//		double a[] = new double[n];
//		String y[] = in.readLine().split(" ");
//		double max = 0;
//		for (int i = 0; i < a.length; i++) {
//			a[i] = Double.parseDouble(y[i]);
//			max=Math.max(max, a[i]);
//		}
//	
//		for (int i = 0; i < n; i++) {
//			for (int j = i + 1; j < n; j++) {
//				double ans = 0.0;
//				double sum = 1.0;
//				for (int j2 = i; j2 <= j; j2++) {
//					sum *= ((double)1.0 -(double) a[j2]);
//				}
//				for (int k = i; k <= j; k++) {
//					ans += ((double)a[k] * ((double)sum / (double)(1.0 - (double)a[k])));
//				}
//				//System.out.println(ans);
//				max=Math.max(ans, max);
//			}
//		}
//	out.printf("%.6f\n",max);
//
//		out.close();
//
//	}
//}
import java.awt.GradientPaint;
import java.awt.geom.Line2D;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;

public class a {
	public static class node {
		long one;
		long two;

		node(long index, long val) {
			one = index;
			two = val;

		}

	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder q = new StringBuilder();
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		String u = in.readLine();
		int n = Integer.parseInt(in.readLine());
		int sum = u.length() + n;
		int st = sum / 2;
		boolean flag = true;

		for (int i = st; i >= 1 && flag; i--) {

			for (int j2 = 0; j2 < u.length() && flag; j2++) {
				if (u.length() - j2 + n >= i * 2) {
					int j;
					for (j = j2; j < i; j++) {
						if (j + i >= u.length()) {
							continue;
						}
						if (u.charAt(j) != u.charAt(j + i))
							break;
					}

					if (j == i) {
						System.out.println(i * 2);
						flag = false;
						break;
					}
				} else
					break;

			}

		}
		if (flag)
			System.out.println(2);

		out.close();

	}
}