B - Before it’s too late

Languages: C, C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
4 1 4 6 3
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
5
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
2 1000000000 1
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
999999999
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
5 1 1 1 1 1
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
0
--- Showing first 30 lines (click "Copy" to get full content) ---

Notes