Problem1433--Heidi and Library (medium)

1433: Heidi and Library (medium)

Time Limit: 2 Sec  Memory Limit: 256 MB
Submit: 0  Solved: 0
[Submit] [Status] [Web Board] [Creator:]

Description

time limit per test
10 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences.

Input

Same as the easy version, but the limits have changed: 1≤n,k≤400000.

Output

Same as the easy version.

Examples
Input
4 100
1 2 2 1
Output
2
Input
4 1
1 2 2 1
Output
3
Input
4 2
1 2 3 1
Output
3

Source/Category