program ee2;
var
ss,p,i:longint;
m,s,t:array[1..25000004] of longint;
begin
assign(input,'goat.in');
assign(output,'goat.out');
reset(input); rewrite(output);
readln(ss,p);
m[1]:=0; s[1]:=0; t[1]:=0;
for i:=1 to ss-1 do
begin
if s[i]>=ss then begin writeln(i-1); exit end;
if (m[i]+5<p) or (m[i]+5=p) and (s[i]+10>=ss)
then begin
m[i+1]:=m[i]+5;
s[i+1]:=s[i]+10
end
else
if (m[i]+2<p) or (m[i]+2=p)and (s[i]+5>=ss)
then
begin
m[i+1]:=m[i]+2;
s[i+1]:=s[i]+5
end
else begin
m[i+1]:=m[i]-1;
s[i+1]:=s[i]+1
end;
end;
close(input); close(output);
end.