#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
const int N=100005;
vector<int> G[N];
vector<int> node[N],nonleaf[N];
int D=1,d[N];
void dfs(int x) {
	node[d[x]].push_back(x);
	if (G[x].size()>0) nonleaf[d[x]].push_back(x);
	for (int i=0; i<G[x].size(); i++) {
		int v=G[x][i];
		d[v]=d[x]+1;
		D=max(D,d[v]);
		dfs(v);
	}
}
const int inf=1<<28;
vector<int> vec;
int b[N],cnt[N];
bool dp[450][N];
vector<char> ans[N];
char res[N];
int main() {
	int n=read(),x=read();
	for (int i=2; i<=n; i++) {
		int p=read();
		G[p].push_back(i);
	} 
	d[1]=1;
	dfs(1);
	for (int i=1; i<=D; i++) {
		b[i]=node[i].size();
		if (cnt[b[i]]==0) vec.push_back(b[i]);
		++cnt[b[i]];
	}
	dp[0][0]=true;
	int sum=0;
	for (int i=1; i<=vec.size(); i++) {
		int val=vec[i-1],tot=val*cnt[val];
		sum+=tot;
		for (int j=0; j<val; j++) {
			int last=-inf;
			for (int k=j; k<=sum; k+=val) {
				if (dp[i-1][k]) last=k;
				if (last!=-inf && k-last<=tot) dp[i][k]=true;	
				else dp[i][k]=dp[i-1][k];	
			}
		}
	}
	if (dp[vec.size()][x]) {
		int now=x;
		for (int i=vec.size(); i>=1; i--) {
			int pre=now;
			while (!dp[i-1][pre]) pre-=vec[i-1];
			for (int j=0; j<now-pre; j++) {
				ans[vec[i-1]].push_back('a');	
			}
			for (int j=now-pre; j<vec[i-1]*cnt[vec[i-1]]; j++) {
				ans[vec[i-1]].push_back('b');	
			}
			now=pre;
		}
		printf("%d\n", D);
		for (int i=1; i<=D; i++) {
			for (int j=0; j<node[i].size(); j++) {
				int p=node[i][j];
				res[p]=ans[b[i]].back();
				ans[b[i]].pop_back();
			}
		}
		for (int i=1; i<=n; i++) printf("%c", res[i]);
		printf("\n");
	}
	else {
		printf("%d\n", D+1);
		int m=n,y=x;
		for (int i=1; i<=D; i++) {
			if (b[i]<=y) {
				for (int j=0; j<node[i].size(); j++) {
					int p=node[i][j];
					res[p]='a';
				}
				y-=b[i];
				m-=b[i];
			}
			else if (b[i]<=m-y) {
				for (int j=0; j<node[i].size(); j++) {
					int p=node[i][j];
					res[p]='b';
				}
				m-=b[i];
			}
			else {
				int tmp=nonleaf[i].size();
				if (tmp<=y) {
					for (int j=0; j<nonleaf[i].size(); j++) {
						int p=nonleaf[i][j];
						res[p]='a';
					}
					y-=tmp;
					m-=tmp;
					for (int j=0; j<node[i].size(); j++) {
						int p=node[i][j];
						if (G[p].size()==0) {
							if (y>0) {
								--y;
								res[p]='a';
							}
						} 
					}
					for (int j=1; j<=n; j++) {
						if (res[j]==0) res[j]='b';
					}
					break;
				}
				else {
					for (int j=0; j<nonleaf[i].size(); j++) {
						int p=nonleaf[i][j];
						res[p]='b';
					}
					m-=tmp;
					for (int j=0; j<node[i].size(); j++) {
						int p=node[i][j];
						if (G[p].size()==0) {
							if (m>y) {
								--m;
								res[p]='b';
							}
						} 
					}
					for (int j=1; j<=n; j++) {
						if (res[j]==0) res[j]='a';
					}
					break;
				}
			}
		}
		for (int i=1; i<=n; i++) printf("%c", res[i]);
		printf("\n");
	}
	return 0;
}
