"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

//var myOut = main();
//if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next();
  var a = nexts(n);
  var g = xArray("[]",n);
  for(var i = 1; i < n; i++){
    g[a[i]-1].push(i);
  }
  var ans = 0;
  if(a[0] !== 1)ans = 1;
  dfs(0,0);
  return ans;
  function dfs(v,depth){
    var dmax = depth;
    for(var i = 0; i < g[v].length; i++){
      var V = g[v][i];
      var d = dfs(V,depth+1);
      if(dmax < d)dmax = d;
    }
    if(v && depth > 1 && dmax >= depth+k-1)ans++, dmax = depth-1;
    return dmax;
  }
}

if (process.argv[2] === "--stack-size=262144" || process.argv.length < 2) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=480000"] });
else {
  var myOut = main();
  if(myOut !== undefined)console.log(myOut);
}