N = gets.to_i a = [0, 1, 2, 3, 2] puts (0 .. 10**18).bsearch { |n| max = ([0, n-4].max..n).map { |i| i / 5 + a[i % 5] }.max max >= N }