X = gets.to_i A = [2, 2, -1, -1, 2, -1, -1] cur = 0 i = 0 ans = 0 while cur != X cur += A[i] ans += A[i].abs i = (i + 1) % 7 end puts ans