#include<bits/stdc++.h>
#define close ios::sync_with_stdio(false)
using namespace std;
const int maxn=1e5+100;
int n,x,maxnum=0,maxdep=0,object_num=0,val[maxn],judge[maxn],deep[maxn],leaf[maxn];
vector<int> G[maxn],depth[maxn],cnt[maxn];
bitset<maxn> b[2100];
void DFS(int root,int dep)
{
	if(dep>maxdep) maxdep=dep;
	deep[root]=dep;
	depth[dep].push_back(root);
	if(G[root].size()==0) leaf[dep]++;
	for(auto cur:G[root]) DFS(cur,dep+1);
}
void Find(int x)
{
	for(int i=object_num;i>0;--i)
	{
		int size=cnt[val[i]].size();
		for(int j=0;j<size;++j){
			if(val[i]>x || b[i-1][x]) break;
			x-=val[i],judge[cnt[val[i]][j]]=1;
		}
	}
}
int main()
{
	close;cin>>n>>x;
	for(int i=2;i<=n;++i){int fa;cin>>fa;G[fa].push_back(i);}
	DFS(1,1);
	for(int i=1;i<=x;++i){
		int size=depth[i].size();
		if(size>maxnum) maxnum=size;
		cnt[size].push_back(i);
	}
	b[object_num][0]=1;
	for(int i=1;i<=maxnum;++i){
		int size=cnt[i].size();
		if(size==0) continue;
		val[++object_num]=i;
		b[object_num]=b[object_num-1];
		for(int j=1;j<=size;j<<=1){
			size-=j;
			b[object_num]|=(b[object_num]<<(i*j));
		}
		if(size>0) b[object_num]|=(b[object_num]<<(i*size));
	}
	if(b[object_num][x]){
		cout<<maxdep<<endl;
		Find(x);
		for(int i=1;i<=n;++i) cout<<(judge[deep[i]]?'a':'b');
	}
	else{
		int res;
		for(int i=x;i>=0;--i){if(b[object_num][i]) {res=i;break;}}
		Find(res);int pos;res=x-res;
		for(int i=1;i<=maxdep;++i)
			if(!judge[i] && leaf[i]>=res) {pos=i;break;}
		cout<<maxdep+1<<endl;
		for(int i=1;i<=n;++i){
			if(judge[deep[i]]) cout<<'a';
			else if(deep[i]==pos && res>0 && G[i].size()==0) cout<<'a',res--;
			else cout<<'b';
		}
	}
}
