program goat;
var
min,s:longint;
p:byte;
procedure go(d,tir,time:longint);
var i:byte;
begin
if d>=s then begin
if min>time then min:=time;
end
else begin
for i:=1 to 3 do begin
case i of
1:if tir=0 then go(d+1,0,time+1) else go(d+1,tir-1,time+1);
2:if tir+2<=p then go(d+5,tir+2,time+1);
3:if tir+5<=p then go(d+10,tir+5,time+1);
end;
end;
end;
end;
begin
assign (input,'goat.in');
reset (input);
readln (s,p);
close (input);
assign (output,'goat.out');
rewrite (output);
min:=maxlongint;
go(0,0,0);
writeln (min);
close (output);
end.