#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const ll root = 3;
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
int par[mxN];
vector<int> adj[mxN];
int n, x;
int depth[mxN];
int mxd[mxN];
vector<int> atd[mxN];
vector<int> atl[mxN];
int sz[mxN];
int restore[mxN];
bool knapsack[mxN];
int flip[mxN];
int res[mxN];
void dfs(int u, int p = -1) {
    for(int v: adj[u]) {
        if(v^p) {
            depth[v] = depth[u] + 1;
            dfs(v, u);
            mxd[u] = max(mxd[u], mxd[v]);
        }
    }
    mxd[u] = max(mxd[u], depth[u]);
    atd[depth[u]].senpai(u);
    if(adj[u].size()==0)atl[depth[u]].senpai(u);
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>x;
    owo(i, 1, n) {
        cin>>par[i];
        par[i]--;
        adj[par[i]].senpai(i);
    }
    dfs(0);
    vector<ttgl> lf;
    owo(i, 0, n) {
        if((int)atd[i].size() > 0) {
            sz[(int)atd[i].size()]++;
        }
        if((int)atl[i].size() > 0)lf.senpai({(int)atl[i].size(), i});
    }
    sort(lf.rbegin(), lf.rend());
    vector<ttgl> items; //cnt: weight
    owo(i, 0, n + 1) {
        int num = 1;
        int s = sz[i];
        while(s >= num) {
            items.senpai({num, i});
            s-=num;
            num*=2;
        }
        if(s)items.senpai({s, i});
    }
    memset(restore, -1, sizeof(restore));
    knapsack[0] = 1;
    int mxitem = 0;
    owo(i, 0, items.size()) {
        owo(j, 0, mxitem + 1) {
            int nxt = j + items[i].first * items[i].second;
            if(nxt >= mxN)break;
            if(knapsack[j] == 1 && restore[j]!= i && knapsack[nxt] == 0) {
                knapsack[nxt] = 1;
                restore[nxt] = i;
                mxitem = max(mxitem, nxt);
            }
        }
    }
    ttgl best {INF, -1};
    owo(i, 0, mxN) {
        if(knapsack[i]) {
            best = min(best, {abs(i - x), i});
        }
    }
    int curr = best.second;
    while(curr!=0) {
        int id = restore[curr];
        flip[items[id].second]+=items[id].first;
        curr-=items[id].second*items[id].first;
    }
    vector<int> d(n);
    iota(d.begin(), d.end(), 0);
    if(best.second > x) {
        sort(d.begin(), d.end(), [&](int a, int b) {
            return atl[a].size() > atl[b].size(); 
        });
    }else {
        sort(d.begin(), d.end(), [&](int a, int b) {
            return atl[a].size() < atl[b].size(); 
        });
        
    }
    owo(i, 0, n) {
        //if(atl[d[i]].size() > 0 && x==489)cout<<i<<" "<<atl[d[i]].size()<<"\n";
        if(flip[atd[d[i]].size()] > 0) {
            flip[atd[d[i]].size()]--;
            for(int k: atd[d[i]]) {
                res[k] = 1;
            }
        }
    }
    int bad = 0;
    if(best.first==0) {
        
    }else { //need to flip some leaves
        bad = 1;
        owo(i, 0, lf.size()) {
            if(res[atd[lf[i].second][0]]==0 && best.second < x) { 
                for(int k: atl[lf[i].second]) {
                    res[k] = 1;
                    best.first--;
                    if(best.first==0)break;
                }
                break;
            }else if(res[atd[lf[i].second][0]]==1 && best.second > x) {
                for(int k: atl[lf[i].second]) {
                    res[k] = 0;
                    best.first--;
                    if(best.first==0)break;
                }
                break;
            }
        }
    }
    cout<<(mxd[0] + bad + 1)<<"\n";
    owo(i, 0, n) {
        cout<<(res[i]==1 ? 'a' : 'b');
    }
    return 0;
}