#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; string S; cin >> S; S += 'x'; vector oo(0, 0), ox(0, 0), xx(0, 0); int cnt1 = 0; ll ans = 0; for (int i = 0, o = 0, cnt = 0; i <= N; i++) { if (S[i] != '-') { if (S[i] == 'o') ans += 1; if (cnt == 0) { o = (S[i] == 'o' ? 1 : 0); continue; } if (S[i] == 'o') o += 1; switch (o) { case 0: xx.push_back(cnt); break; case 1: if (cnt == 0) cnt1 += 1; else ox.push_back(cnt); break; case 2: oo.push_back(cnt); break; } cnt = 0; o = (S[i] == 'o' ? 1 : 0); } else { cnt += 1; } } sort(oo.begin(), oo.end(), [](int a, int b) { if (a % 2 != b % 2) { return (a % 2 == 1); } return a < b; }); sort(ox.begin(), ox.end()); sort(xx.begin(), xx.end(), greater()); for (int i : oo) { if (i / 2 <= M) { ans += i; M -= i / 2; } else { ans += M * 2; M = 0; } } for (int i : ox) { if (i / 2 <= M) { ans += i - i % 2; M -= i / 2; cnt1 += i % 2; } else { ans += M * 2; M = 0; } } for (int i : xx) { if ((i + 1) / 2 <= M) { cnt1 += 1 - i % 2; ans += i - 1 + i % 2; M -= (i + 1) / 2; } else if (M > 0) { ans += M * 2 - 1; M = 0; } } ans += min(M, cnt1); cout << ans << '\n'; }