local n, k = io.read("*n", "*n")
local edge = {}
local len = {}
for i = 1, n do
  edge[i] = {}
  len[i] = -1
end
len[1] = 0
local ret = io.read("*n") == 1 and 0 or 1
for i = 2, n do
  local a = io.read("*n")
  table.insert(edge[a], i)
  table.insert(edge[i], a)
end
local tasks = {1}
for it = 1, n do
  local src = tasks[it]
  for i = 1, #edge[src] do
    local dst = edge[src][i]
    if len[dst] == -1 then
      len[dst] = len[src] + 1
      table.insert(tasks, dst)
    end
  end
end
-- reuse "tasks"
for i = 1, n do
  tasks[i] = i
end
table.sort(tasks, function(a, b) return len[a] < len[b] end)
local offset = 0
for i = 2, n do
  if len[tasks[i]] - offset == k + 1 then
    ret = ret + 1
    if i < n and k + 1 < len[tasks[i + 1]] - offset then
      offset = offset + k
    end
  end
end
print(ret)
