n = gets.to_i
have = [n,0,0,0]
exc1 = gets.split.map(&:to_i)
exc2 = gets.split.map(&:to_i)

inst = 1.0
check = -1
for i in 0..2
  if inst < exc2[i] / exc1[i]
    inst = exc2[i].to_f / exc1[i]
    check = i
  end
end
have[check+1] = have[0]/exc1[check] if inst != 1.0
have[0] -= have[check+1]*exc1[check] if inst != 1.0

have[0] += have[check+1]*exc2[check] if inst != 1.0
have[check+1] = 0 if inst != 1.0


inst = 1.0
check = -1
for i in 0..2
  if inst < exc1[i] / exc2[i]
    inst = exc1[i].to_f / exc2[i]
    check = i
  end
end
have[check+1] = have[0]/exc2[check] if inst != 1.0
have[0] -= have[check+1]*exc2[check] if inst != 1.0

have[0] += have[check+1]*exc1[check] if inst != 1.0
have[check+1] = 0 if inst != 1.0

puts have[0]
