1 #include
2 #include
3 #include <string.h>
4 #include
5
6 using namespace std;
7
8 int n,w;
9 int ans=0;
10 stack<int> stk;
11
12 int main()
13 {
14 cin>>n>>w;
15 int a,b;
16 for(int i=0;i<=n;i++)
17 {
18 if(i>a>>b;
19 else b=0;
20 while(!stk.empty() && stk.top()>b)
21 {
22 stk.pop();
23 ans++;
24 }
25 if(stk.empty() || stk.top()!=b) stk.push(b);
26 }
27 cout28 }