N = gets.to_i problems = N (1 ..).each do |day| if day % 7 == 0 problems += 6 end problems -= 1 if problems == 0 puts day exit end end