Elephant

Practice this coding question on Coding Gurukul.

Problem statement

A park guide moves along a straight path from marker 0 to a visitor waiting at marker x. Each stride may cover exactly 1, 2, 3, 4 or 5 distance units. The guide wants to reach the visitor using as few strides as possible and must stop at the visitor’s marker without overshooting it. You are writing the step counter used by the route display. Your task For the positive integer distance x, find the minimum number of allowed strides whose lengths add up to x. Stride lengths may be reused, and the guide may choose a different length at each move. Only the minimum count is required, not the sequence of moves. Important details A final shorter stride is allowed. Distances divisible by five do not require an extra move. The route has no obstacles, backward moves or restrictions other than the permitted stride lengths. Worked example To reach marker 12, the guide can take strides of 5, 5 and 2. Two strides cover at most 10, so three is the minimum.

Input format

One integer x.

Output format

Print the minimum number of strides.

Constraints

1 <= x <= 1000000.

Sample input

12

Sample output

3

Sign in to run or submit a solution in C++, Java or Python.