#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int N = (int) 1e6 + 10;
int p[N], h[N], cnt[N], can[N], w[N], n, a, b, maxh;
char res[N];
bool parent[N], ans[N];
vector<int> who[N], which[N];
vector<vector<bool>> what;

int get(int i) {
	if (i == 0) return 0;
	if (h[i] != -1) return h[i];
	return h[i] = get(p[i]) + 1;
}

int main() {
	scanf("%d%d", &n, &a), b = n - a;
	for (int i = 1; i < n; ++i) {
		scanf("%d", &p[i]), p[i]--;
		parent[p[i]] = true;
	}
	for (int i = 0; i < n; ++i) {
		h[i] = -1;
	}
	for (int i = 0; i < n; ++i) {
		h[i] = get(i);
		cnt[h[i]]++;
		which[h[i]].push_back(i);
		maxh = max(maxh, h[i]);
	}
	for (int i = 0; i <= n; ++i) {
		w[cnt[i]]++;
		who[cnt[i]].push_back(i);
	}
	vector<bool> tmp(n + 1, false);
	tmp[0] = true;
	what.push_back(tmp);
	for (int i = 1; i <= n; ++i) {
		if (w[i] == 0) continue;
		// fprintf(stderr, "%d : %d\n", i, w[i]);
		for (int j = 0; j <= n; ++j) {
			if (what.back()[j]) can[j] = 0;
			else if (j >= i) can[j] = can[j - i] + 1;
			else can[j] = N;
		}
		for (int j = 0; j <= n; ++j) {
			tmp[j] = (can[j] <= w[i]);
			// fprintf(stderr, "%c", "01"[tmp[j]]);
		}
		// fprintf(stderr, "\n");
		what.push_back(tmp);
	}
	if (what.back()[a]) {
		printf("%d\n", maxh + 1);
		for (int i = n; i >= 1; --i) {
			if (w[i] == 0) continue;
			what.pop_back();
			for (int j = 0; (j <= w[i]) && (j * i <= a); ++j) {
				if (what.back()[a - i * j]) {
					// fprintf(stderr, "can take %d copies of %d\n", j, i);
					for (int k = 0; k < j; ++k) {
						ans[who[i][k]] = true;
					}
					a -= i * j;
					break;
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			printf(ans[h[i]] ? "a" : "b");
		}
		printf("\n");
		return 0;
	}
	printf("%d\n", maxh + 2);
	char ca = 'a', cb = 'b';
	for (int i = 0; i <= n; ++i) {
		if (a < b) swap(a, b), swap(ca, cb);
		if (cnt[i] <= a) {
			for (int j : which[i]) {
				res[j] = ca;
			}
			a -= cnt[i];
		} else {
			for (int j : which[i]) {
				if (parent[j]) {
					res[j] = cb;
					--b;
				}
			}
			for (int j : which[i]) {
				if (!parent[j]) {
					if (b > 0) {
						res[j] = cb;
						--b;
					} else {
						res[j] = ca;
						--a;
					}
				}
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		printf("%c", res[i]);
	}
	printf("\n");
	return 0;
}