///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 3e5 + 10;
ll n, val, h;
ll A[MXN], dis[MXN], dp[MXN], par[MXN];
vector<ll> adj[MXN], H[MXN], leaf, non;
map<ll, vector<ll>> mp;
string ANS;
void dfs(ll u, ll pr){
    A[dis[u]] ++, h = max(h, dis[u]);
    H[dis[u]].push_back(u);
    for(auto v : adj[u]){
        if(v != pr) dis[v] = dis[u] + 1, dfs(v, u);
    }
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> val; ll bvl = val;
    for(int i = 0; i < n; i ++) ANS += "a";
    for(int i = 2; i <= n; i ++){
        ll p; cin >> p;
        adj[p].push_back(i), adj[i].push_back(p);
    }
    dfs(1, 0);
    for(int i = 0; i <= h; i ++) mp[A[i]].push_back(i);
    dp[0] = 1;
    for(auto itr : mp){
        ll x = itr.first, cnt = 0;
        for(auto r = 0; r < x; r ++){
            for(int k = r; k <= n; k += x){
                if(dp[k]) cnt = (itr.second).size();
                else if(cnt){
                    dp[k] = 1, cnt --;
                    par[k] = (itr.second)[cnt];
                }
            }
        }
    }
    if(dp[val]){
        cout << h + 1 << '\n';
        while(val){
            for(auto u : H[par[val]]) ANS[u - 1] = 'b';
            val -= A[par[val]];
        }
    }
    else{
        cout << h + 2 << '\n';
        for(int i = 0; i <= h; i ++){
            if(val >= A[i]){
                for(auto u : H[i]) ANS[u - 1] = 'b';
                val -= A[i]; continue;
            }
            for(auto u : H[i]){
                if(adj[u].size() == 1) leaf.push_back(u);
                else non.push_back(u);
            }
            if(val < non.size() && val > leaf.size()){
                leaf.clear(), non.clear();
                continue;
            }
            if(val > leaf.size()){
                for(auto u : non) ANS[u - 1] = 'b';
                val -= int(non.size());
            }
            for(int j = 0; j < val; j ++){
                ANS[leaf[j] - 1] = 'b';
            }
            break;
        }
    }
    for(int i = 0; i < n; i ++)
        ANS[i] = char((!(ANS[i] - 'a')) + 'a');
    cout << ANS << '\n';
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N
