J - Wired Connection

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

Input

Output

Sample test(s)

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

Notes