#include <bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define fr first
#define sc second
#define pii pair<int, int>
using namespace std;
const int N = 100005;

int n, x, p;
vector<int> to[N], cs[N];
int dep[N], mxdep, sz[N];
int v[N], c[N];
int f[2][N], pre[N], id[N], idx, g[N], col[N], num[N];

void dfs(int u, int depth) {
    dep[u] = depth;
    mxdep = max(mxdep, depth);
    sz[dep[u]]++;
    for (auto v : to[u]) dfs(v, depth+1);
}
int main() {
    scanf("%d%d", &n, &x);
    for (int i = 2; i <= n; i++) {
        scanf("%d", &p);
        to[p].pb(i);
    }
    dfs(1, 1);
    for (int i = 1; i <= mxdep; i++) {
        if (!id[sz[i]]) id[sz[i]] = ++idx;
        ++c[id[sz[i]]];
        cs[sz[i]].pb(i);
        v[id[sz[i]]] = sz[i];
    }

    f[0][0] = 1;
    int zs = 1;
    for (int i = 1; i <= idx; i++) {
        g[0] = 0;
        for (int j = 1; j < v[i]; j++) g[j] = -1;
        for (int j = 0; j <= x; j++) f[zs][j] = 0;
        for (int j = 0; j <= x; j++) {
            if (j >= v[i] && !f[zs^1][j]) {
                f[zs][j] = (g[j%v[i]] != -1 && (j-g[j%v[i]])/v[i] <= c[i]);
                if (f[zs][j]) pre[j] = g[j%v[i]], num[j] = v[i];
            }
            f[zs][j] |= f[zs^1][j];
            if (f[zs^1][j]) g[j%v[i]] = j;
        }
        zs ^= 1;
    }

    if (f[idx&1][x]) {
        printf("%d\n", mxdep);
        while (x) {
            int t = (x-pre[x])/num[x];
            for (int i = 0; i < t; i++)
                col[cs[num[x]][i]] = 1;
            x = pre[x];
        }
        for (int i = 1; i <= n; i++)
            putchar(col[dep[i]] ? 'a' : 'b');
    } else {
        printf("%d\n", mxdep+1);
        int ra = x, rb = n-x, dp, mc, cnt;
        for (int i = 1; i <= mxdep; i++) {
            if (sz[i] <= ra) col[i] = 1, ra -= sz[i];
            else if (sz[i] <= rb) rb -= sz[i];
            else {dp = i, mc = ra < rb, cnt = sz[i]-(ra < rb ? rb : ra); break; }
        }
        for (int i = 1; i <= n; i++)
            if (dep[i] < dp) putchar(col[dep[i]] ? 'a' : 'b');
            else if (dep[i] > dp) putchar(mc ? 'a' : 'b');
            else if (!to[i].size() && cnt) putchar(mc ? 'a' : 'b'), --cnt;
            else putchar(mc ? 'b' : 'a');
    }
        
    return 0;
}
