#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define fors(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
int n, d;
const int maxn = 1e5 + 5;
int fa[maxn];
vector<int> g[maxn];
int dep[maxn];
vector<int> f[maxn];
vector<int> h[maxn];
int mxd = 0;
void dfs(int u){
    dep[u] = dep[fa[u]]+1; f[dep[u]].pb(u);
    mxd = max(mxd, dep[u]);
    for(int v: g[u]) dfs(v);
}
int tmp[maxn], dp[maxn], cnt[maxn];
#define P pair<int,int>
vector<P> path;
int ans[maxn];
int main()
{
    cin>>n>>d;
    int C = d;
    fors(i,2,n+1) scanf("%d", &fa[i]), g[fa[i]].pb(i);
    dfs(1);
    fors(i,1,mxd+1){
        int num = f[i].size(); h[num].pb(i);
    }
    memset(dp, -1, sizeof dp);
    dp[0] = 0;
    fors(i,1,n+1){//一层的点数
        if(!h[i].size()) continue;//i个点的
        int num = h[i].size();//有num个i点层
        fors(j,0,C+1) tmp[j] = dp[j];
        for(int j = 0; j < i; ++j){//模数为j j,j+i,j+2i ... j+ki
            int last = -1e9;
            for(int k = 0; j + k*i <= C; ++k){
                int cur = j+k*i;
               // cout<<"i:"<<i<<" j:"<<j<<" k:"<<k<<" last:"<<last<<endl;
                if(~dp[cur]) last = cur;
                else if(last >= cur-num*i){
                    dp[cur] = i;
                    cnt[cur] = (cur-last)/i;
                }
            }
        }
    }
    if(~dp[C]){
        printf("%d\n", mxd);
        int cur = C;
        while(cur){
            fors(i,0,cnt[cur]){
                int dd = h[dp[cur]][i];
                for(int x: f[dd]) ans[x] = 1;
            }
            cur -= cnt[cur]*dp[cur];
        }
    }else{
        printf("%d\n", mxd+1);
        int a = d, b = n-d;
        fors(i,1,mxd+1){
            int num = f[i].size();
            if(a >= num) {for(int x: f[i]) ans[x] = 1; a-=num;}
            else if(b >= num) b -= num;
            else{
                static vector<int> t, le;
                for(int x: f[i]) if(g[x].size()) t.pb(x); else le.pb(x);
                if(t.size() <= a) {//非叶子填a
                        for(int x:t) ans[x] = 1; a -= t.size();
                        for(int x:le){
                            a--; ans[x] = 1; if(a==0) break;
                        }
                        break;
                }
                int ned = num-b;
                for(int x: le){
                    ned--; ans[x] = 1; if(ned == 0) break;
                }
                a -= ned; b = 0;
            }
        }
    }
    fors(i,1,n+1) printf(ans[i]?"a":"b");
	return 0;
}
