-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path5525.cpp
54 lines (54 loc) · 966 Bytes
/
5525.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
#define MOD 1000000007ll
#define MAX 2000000000ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef queue<int> qi;
typedef queue<pair<int, int>> qii;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;
ll a[1 << 21];
int main() {
cin.tie(NULL); ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
string str;
cin >> str;
int cnt = 0;
int flag = 0;
int ans = 0;
for (int i = 0; i < m; i++) {
if (flag) {
if (str[i] == 'O') {
flag = 0;
cnt++;
}
else {
flag = 1;
cnt = 1;
}
}
else {
if (str[i] == 'I') {
cnt++;
flag = 1;
}
else {
flag = 0;
cnt = 0;
}
}
if (cnt == n * 2 + 1) {
cnt -= 2;
ans++;
}
}
cout << ans;
return 0;
}