#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
#define Ri register
typedef long long ll;

const int N = 1e5 + 100, M = 500;

int n, f[N], son[N], dep[N], A, B, maxdep;
int ansnum, ls[N], tot, fre[N], dp[M][N];
char ans[N];
vector<int> ed[N], d[N];
int cnt[N];

void dfs(int u) {
    dep[u] = dep[f[u]]+ 1;
    d[dep[u]].push_back(u);
    maxdep = max(maxdep, dep[u]);
    for (auto v : ed[u]) {
        if (v == f[u]) continue;
        dfs(v);
    }
}

int Find(int x) {
    return lower_bound(ls + 1, ls + 1 + tot, x) - ls;
}

int cmp(int a, int b) {
    return son[a] > son[b];
}

void findcnt(int layer, int cur) {
    if (layer == 0) return;
    cnt[layer] = dp[layer][cur];
    findcnt(layer-1, cur - cnt[layer] * ls[layer]);
}

void solve(int pos) {
    int num = d[pos].size();
    if (min(A, B) >= num) {
        if (A > B) {
            for (auto i : d[pos])
                ans[i] = 'b';
            B -= num;
        }
        else {
            for (auto i : d[pos])
                ans[i] = 'a';
            A -= num;
        }
    }
    else if (max(A, B) >= num) {
        if (A >= num) {
            for (auto i : d[pos])
                ans[i] = 'a';
            A -= num;
        }
        else {
            for (auto i : d[pos])
                ans[i] = 'b';
            B -= num;
        }
    }
    else {
        ansnum++;
        if (A > B) {
            for (auto i : d[pos]) {
                if (A) { ans[i] = 'a'; A--; }
                else { ans[i] = 'b'; B--; }
            }
        }
        else {
            for (auto i : d[pos]) {
                if (B) {ans[i] = 'b'; B--;}
                else {ans[i] = 'a'; A--;}
            }
        }
    }
}

int main() {
    scanf("%d%d", &n, &A);
    B = n - A;
    for (int i = 2; i <= n; ++i) {
        scanf("%d", &f[i]);
        son[f[i]]++;
        ed[i].push_back(f[i]);
        ed[f[i]].push_back(i);
    }
    dfs(1);
    ansnum = maxdep;
    for (int i = 1; i <= maxdep; ++i)
        sort(d[i].begin(), d[i].end(), cmp);
    for (int i = 1; i <= maxdep; ++i)
        ls[i] = d[i].size();
    tot = maxdep;
    sort(ls + 1, ls + 1 + tot);
    tot = unique(ls + 1, ls + 1 + tot) - ls - 1;
    for (int i = 1; i <= maxdep; ++i)
        fre[Find(d[i].size())]++;

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 1;    
    for (int i = 1; i <= tot; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (dp[i - 1][j] >= 0) 
                dp[i][j] = 0;
            else if (j - ls[i] >= 0 && dp[i][j - ls[i]] >= 0 && dp[i][j - ls[i]] < fre[i])
                dp[i][j] = dp[i][j - ls[i]] + 1;
        }
    }
    if (dp[tot][A] >= 0) {
        findcnt(tot, A);
        for (int i = 1; i <= maxdep; ++i) {
            int x = Find(d[i].size());
            if (cnt[x]) {
                cnt[x]--;
                for (auto j : d[i])
                    ans[j] = 'a';
            }
            else {
                for (auto j : d[i])
                    ans[j] = 'b';
            }
        }
        printf("%d\n", maxdep);
        printf("%s\n", ans + 1);
        return 0;
    }
    for (int i = 1; i <= maxdep; ++i) {
        solve(i);
    }    
    printf("%d\n", ansnum);
    printf("%s\n", ans + 1);
    return 0;
}