#include<bits/stdc++.h>
using namespace std;

#define ll   long long
#define ull  long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn =1e5+100;
const ll mod=998642767 ;
const ll base=317;

vector<ll> adj[maxn];
ll dep[maxn];
vector<ll> gr[maxn];
vector<ll> gr1[maxn];

ll mx=-1;
ll dp[maxn][2];
void dfs(ll u,ll par)
{
    mx=max(mx,dep[u]);
    gr[dep[u]].pb(u);
   for (auto to:adj[u])
   {
       dep[to]=dep[u]+1;
       dfs(to,u);
   }
}
ll cntnw[maxn];
ll gtx[maxn];
char res[maxn];
ll pos[maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TRIPLES.inp","r"))
    {
        freopen("TRIPLES.inp","r",stdin);
        freopen("TRIPLES.out","w",stdout);
    }
   ll n, x;
    cin>>n>> x;
    for (int i=2;i<=n;i++)
    {
        ll x;
         cin>>x;
       adj[x].pb(i);
    }
    dep[1]=1;
    dfs(1,0);
    vector<ll> vt;
    for (int i=1;i<=mx;i++)
    {
        vt.pb(gr[i].size());
    //    cout <<gr[i].size()<<endl;
        gr1[gr[i].size()].pb(i);
    }
    sort(vt.begin(),vt.end());
    dp[0][0]=1;
    ll pre=0;
    for (int i=0;i<vt.size();i++)
    {
       ll j=i;
       while (j<vt.size()&&vt[j]==vt[i])
       {
           j++;
       }
       j--;
       ll nw=1-pre;
       ll cnt=(j-i+1);
       ll t=vt[j];
       //cout <<t<<" "<<cnt<<" "<<nw<<endl;
       for (ll i=0;i<=n;i++)
       {
          cntnw[i%t]+=dp[i][pre];
         // cout <<dp[i][pre]<<endl;
          //  cout <<cntnw[i%t]<<endl;
          if (i>=(cnt+1)*t) cntnw[i%t]-=dp[i-(cnt+1)*t][pre];
          // cout <<cntnw[i%t]<<endl;
          if (cntnw[i%t]) dp[i][nw]=1;
          if (!dp[i][pre]&&dp[i][nw]) gtx[i]=t;
       }
       for (int i=0;i<=n;i++) dp[i][pre]=0;
     /*  for (int i=0;i<=n;i++) cout <<dp[i][nw]<<" ";
       cout <<endl;*/
       for (int t=0;t<=vt[j];t++) cntnw[t]=0;
       i=j;
       pre=nw;
    }
  /*  for (int i=0;i<=n;i++)
    {
        cout <<dp[i][pre]<<endl;
    }*/
    for (int i=1;i<=n;i++) res[i]='b';
    if (dp[x][pre])
    {
       //  cout <<"WTF"<<endl;
        cout <<mx<<endl;
        while (x)
        {
            ll h=gtx[x];
            ll cnt=0;
            while (1)
            {
                cnt++;
                x-=h;
                if (dp[x][pre]) break;
            }
            for (int i=pos[h];i<pos[h]+cnt;i++)
            {
                ll t=gr1[h][i];
                for (auto to:gr[t]) res[to]='a';
            }
            pos[h]+=cnt;
          //  cout <<cnt<<" "<<h<<endl;
        }
        for (int i=1;i<=n;i++) cout <<res[i];
    }
    else
    {
      //  cout <<"WTF"<<endl;
        cout <<mx+1<<endl;
        vector<ll> remain;
        ll nw=n;
        vector<ll> vt1;
        for (int i=1;i<=mx;i++)
        {
             if (x>=gr[i].size())
             {
                 for (auto to:gr[i]) res[to]='a';
                 x-=gr[i].size();
                 nw-=gr[i].size();
             }
             else if (nw-x>=gr[i].size())
             {
                 nw-=gr[i].size();
             }
             else
             {
                 vector<ll> vt;

                  for (auto to:gr[i])
                  {
                      if (adj[to].size()) vt.pb(to);
                      else vt1.pb(to);
                  }
                  if (x>=vt.size())
                  {
                      for (auto to:vt) res[to]='a';
                      x-=vt.size();
                  }
                  else
                  {

                  }
                  nw-=vt.size();
             }
        }
        for (auto to:vt1)
        {
            if (x)
            {
                x--;
                res[to]='a';
            }
        }
        for (int i=1;i<=n;i++) cout <<res[i];
    }





}


