program goat;
var
f: array[0..1,0..100] of longint;
S,P: longint;
procedure init;
var
i: longint;
begin
readln(S,P);
dec(P);
end;
Procedure Print(ans: longint);
begin
writeln(ans);
close(input); close(output);
halt;
end;
procedure main;
var
j,k,Time:longint;
begin
Time:=0; k:=1;
repeat
inc(Time);
for j:=0 to P do
begin
f[k][j]:=f[1-k][j];
if j+1<=P then if f[1-k][j+1]+1>f[k][j]
then f[k][j]:= f[1-k][j+1]+1;
if j>=2 then if f[1-k][j-2]+5>f[k][j]
then f[k][j]:= f[1-k][j-2]+5;
if j>=5 then if f[1-k][j-5]+10>f[k][j]
then f[k][j]:= f[1-k][j-5]+10;
end;
if f[1-k][0]+1>f[k][0] then f[k][0]:=f[1-k][0]+1;
if f[k][p]>=S then Print(Time);
k:=1-k;
until false;
end;
begin
assign(input,'goat.in');
assign(output,'goat.out');
reset(input); rewrite(output);
init;
main;
close(input); close(output);
end.