{$M 400000000}
const maxn = 10000;
fi = '';
fo = '';
var k,n,res:word;
a: array[1..maxn] of word;
dp: array[1..maxn] of word;
g: array[1..maxn,0..maxn] of word;
procedure enter;
var i,u:word;
begin
assign(input,fi);
reset(input);
readln(k);
readln(n);
for i:=1 to n do
begin
dp[i]:=0;
g[i,0]:=0;
end;
dp[1]:=1;
a[1]:=0;
for i:=2 to n do
begin
read(a[i]);
inc(g[a[i],0]);
g[a[i],g[a[i],0]]:=i;
u:=i;
repeat
inc(dp[u]);
u:=a[u];
until u=0;
end;
close(input);
end;
procedure dfs(i:longint);
var u,j:word;
begin
for j:=1 to g[i,0] do
dfs(g[i,j]);
if dp[i]>=k then
begin
inc(res);
u:=a[i];
repeat
dec(dp[u],dp[i]);
u:=a[u]
until u=0;
dp[i]:=0;
end;
end;
procedure solve;
begin
assign(output,fo);
rewrite(output);
res:=0;
dfs(1);
writeln(res);
close(output);
end;
begin
enter;
solve;
end.
eyRNIDQwMDAwMDAwMH0KY29uc3QgbWF4biA9IDEwMDAwOwogICAgICBmaSA9ICcnOwogICAgICBmbyA9ICcnOwp2YXIgayxuLHJlczp3b3JkOwogICAgYTogYXJyYXlbMS4ubWF4bl0gb2Ygd29yZDsKICAgIGRwOiBhcnJheVsxLi5tYXhuXSBvZiB3b3JkOwogICAgZzogYXJyYXlbMS4ubWF4biwwLi5tYXhuXSBvZiB3b3JkOwpwcm9jZWR1cmUgZW50ZXI7CnZhciBpLHU6d29yZDsKYmVnaW4KICBhc3NpZ24oaW5wdXQsZmkpOwogIHJlc2V0KGlucHV0KTsKICByZWFkbG4oayk7CiAgcmVhZGxuKG4pOwogIGZvciBpOj0xIHRvIG4gZG8KICBiZWdpbgogICAgZHBbaV06PTA7CiAgICBnW2ksMF06PTA7CiAgZW5kOwogIGRwWzFdOj0xOwogIGFbMV06PTA7CiAgZm9yIGk6PTIgdG8gbiBkbwogIGJlZ2luCiAgICByZWFkKGFbaV0pOwogICAgaW5jKGdbYVtpXSwwXSk7CiAg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