// PascalABC.Net
function dec2bin(n: integer): string;
begin
for var c:=31 downto 0 do
Result += IntToStr((N shr c) and 1);
end;
function count(b: string; c: char): integer;
for var i:=1 to length(b) do
if b[i] = c then
Result += 1;
var N:=32;
var K:=3;
var sum:=0;
for var i:=1 to n do
if count(dec2bin(i), '1') = K then
sum += 1;
writeln(sum);
end.
// PascalABC.Net
function dec2bin(n: integer): string;
begin
for var c:=31 downto 0 do
Result += IntToStr((N shr c) and 1);
end;
function count(b: string; c: char): integer;
begin
for var i:=1 to length(b) do
if b[i] = c then
Result += 1;
end;
begin
var N:=32;
var K:=3;
var sum:=0;
for var i:=1 to n do
if count(dec2bin(i), '1') = K then
begin
sum += 1;
end;
writeln(sum);
end.