#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; string s; cin >> s; assert(3 <= n && n <= 100000); assert(0 <= m && m <= n); // o---o, o--**, **--o が得できそう auto weight = [&](string &t){ if(t == "o---o"){ return 2; } if(t.substr(0, 3) == "o--" || t.substr(2, 3) == "--o"){ return 1; } if(t.substr(1, 3) == "o-o"){ return -1; } if(t[2] == '-'){ return 0; } return -2; }; map> cnt; set> pq; auto get = [&](int i){ string t = ""; for(int j = i - 2; j <= i + 2; j++){ if(0 <= j && j < n){ t += s[j]; }else{ t += "x"; } } return weight(t); }; auto update = [&](int i, char c){ for(int j = i - 2; j <= i + 2; j++){ if(0 <= j && j < n){ pq.erase({get(j), j}); } } s[i] = c; for(int j = i - 2; j <= i + 2; j++){ if(0 <= j && j < n){ pq.insert({get(j), j}); } } }; int ans = 0; for(int i = 0; i < n; i++){ if(s[i] == 'o') ans++; pq.insert({get(i), i}); } int can_op = m; while(can_op > 0 && !pq.empty()){ auto [w, idx] = *(--pq.end()); if(w <= -2) break; can_op--, ans++; update(idx, 'o'); } for(auto [w, idx] : pq){ if(w == -1){ ans++; } } cout << ans << endl; }