begin
var f1 := OpenRead('input.txt');
var f2 := OpenWrite('output_2.txt');
var (a, Count) := (1, 0);
var max := integer.MinValue;
while a <> 0 do
begin
Readln(f1, a);
if a > max then
begin
max := a;
Count := 1
end
else if a = max then
Count += 1
end;
Write(f2, Count);
Close(f1);
Close(f2);
end.