#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

const int maxn=100010;

vector<int> ch[maxn];
vector<int> depnodes[maxn];
int fa[maxn];
int dep[maxn];
int maxdep;
int col[maxn];

void dfs(int n)
{
    dep[n] = dep[fa[n]]+1;
    for (int i=0;i<ch[n].size();i++)
        dfs(ch[n][i]);
}

int depcnt[maxn];
vector<int> idxs[maxn];

struct Node
{
    int nxt;
    int idx;
    int beg;
    int end;
};
int dp[maxn];
Node nxt[maxn];

bool best(int n, int m)
{
    memset(dp, 0, sizeof(dp));
    memset(col, 0, sizeof(col));
    for (int i=0;i<=maxdep;i++)
        idxs[i].clear();

    for (int i=1;i<=maxdep;i++)
        idxs[depcnt[i]].push_back(i);

    vector<int> vecidxs;
    for (int i=0;i<maxn;i++)if(idxs[i].size())
        vecidxs.push_back(i);

    dp[0] = 1;
    for (int j=0;j<vecidxs.size();j++)
    {
        int idx = vecidxs[j];
        int size = idxs[idx].size();
        int beg = 0;
        for (int k=0;k<20&&(1<<k)<=size;k++)
        {
            int delta = (1<<k)*idx;
            for (int i=n-1;i>=0;i--)if(dp[i] && !dp[i+delta])
            {
                dp[i+delta] = 1;
                nxt[i+delta] = {i, idx, beg, beg+(1<<k)};
            }
            size -= (1<<k);
            beg += (1<<k);
        }
        if (size)
        {
            for (int i=n-1;i>=0;i--)if(dp[i] && !dp[i+size*idx])
            {
                dp[i+size*idx] = 1;
                nxt[i+size*idx] = {i, idx, beg, beg+size};
            }
        }
    }
    if (dp[m])
    {
        //printf("\t");
        printf("%d\n", maxdep);
        int cur = m;
        while (cur)
        {
            const Node& node = nxt[cur];
            for (int i=node.beg;i<node.end;i++)
            {
                int d = idxs[node.idx][i];
                //printf("%d ", idxs[node.idx][i]);
                for (int j=0;j<depnodes[d].size();j++)
                    col[depnodes[d][j]]=1;
            }
            cur = node.nxt;
        }
        for (int i=1;i<=n;i++)
            printf("%c", col[i]?'a':'b');
        puts("");
    }
    return dp[m];
}

void gao(int n, int m)
{
    for (int i=1;i<=maxdep;i++)
    {
        if (m>=depcnt[i])
        {
            m-=depcnt[i];
            for (int v : depnodes[i])
                col[v] = 1;
        }
        else
        {
            for (int j=maxdep;j>=i;j--)if(m>=depcnt[j+1] && m<depcnt[j])
            {
                for (int v : depnodes[j+1])
                    col[v] = 1;
                m -= depcnt[j+1];
                for (int v : depnodes[j])if(ch[v].empty())
                {
                    if (m<=0)
                        break;
                    col[v] = 1;
                    m--;
                }
                if (m<=0)
                    break;
            }
            break;
        }
    }
    printf("%d\n", maxdep+1);
    for (int i=1;i<=n;i++)
        printf("%c", col[i]?'a':'b');
    puts("");
}

int main()
{
    int n,m;
    scanf("%d%d", &n,&m);
    for (int i=2;i<=n;i++)
    {
        scanf("%d", &fa[i]);
        ch[fa[i]].push_back(i);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    {
        depcnt[dep[i]]++;
        depnodes[dep[i]].push_back(i);
        maxdep = max(maxdep, dep[i]);
    }
    if (!best(n, m))
        gao(n, m);
}

   	 	 		 		 	  	 		       	 	