var a:array[1..3]of longint;
f:array[1..100001]of longint;
v:array[1..100000]of boolean;
p:array[1..200000]of longint;
head,tail:longint;
s,e,i,now,x,l:longint;
begin
assign(input,'wood.in');reset(input);
assign(output,'wood.out');rewrite(output);
readln(s,e);
for i:=1 to 3 do readln(a[i]);
readln(l);
fillchar(f,sizeof(f),$7f);
f[s]:=0;
head:=0;tail:=1;p[1]:=s;
while head<>tail do
begin
head:=head mod 100000+1;
now:=p[head];v[now]:=false;
for i:=1 to 3 do
begin
x:=now+a[i];
if x<100000 then
if f[x]>f[now]+1 then
begin
f[x]:=f[now]+1;
if not(v[x])then
begin tail:=tail mod 100000+1;p[tail]:=x;v[x]:=true;end;
end;
end;
x:=now-l;
if f[x]>f[now]+1 then
begin
f[x]:=f[now]+1;
if not(v[x])then
begin tail:=tail mod 100000+1;p[tail]:=x;v[x]:=true;end;
end;
x:=l;
if f[x]>f[now]+1 then
begin
f[x]:=f[now]+1;
if not(v[x])then
begin tail:=tail mod 100000+1;p[tail]:=x;v[x]:=true;end;
end;
x:=now div 2;
if x>0 then
if f[x]>f[now]+1 then
begin
f[x]:=f[now]+1;
if not(v[x])then
begin tail:=tail mod 100000+1;p[tail]:=x;v[x]:=true;end;
end;
end;
if f[e]<>f[100001]then writeln(f[e])else writeln('No solution.');
close(output);
end.