#include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { int n, m; cin >> n >> m; string t = ""; vector odd, mid, end, bad; int ans = 0; const auto process = [&]() -> void { if (t.empty()) return; if (ranges::count(t, 'o') == 0) { bad.emplace_back(t.length()); return; } { int bck = 0; for (; t.back() == '-'; t.pop_back()) { ++bck; } if (bck > 0) end.emplace_back(bck); } ranges::reverse(t); { int bck = 0; for (; t.back() == '-'; t.pop_back()) { ++bck; } if (bck > 0) end.emplace_back(bck); } assert(t.front() == 'o'); for (int i = 0; i + 1 < t.length();) { const int j = t.find('o', i + 1); if (j - i == 2) { ++ans; } else { ((j - i) % 2 == 0 ? odd : mid).emplace_back(j - i - 1); } i = j; } ans += ranges::count(t, 'o'); t.clear(); }; while (n--) { char s; cin >> s; if (s == 'x') { process(); } else { t += s; } } process(); ranges::sort(odd); for (const int len : odd) { if (len / 2 <= m) { m -= len / 2; ans += len; } else { ans += m * 2; m = 0; } } for (const int len : mid) { if (len / 2 <= m) { m -= len / 2; ans += len; } else { ans += m * 2; m = 0; } } for (int len : end) { if (len % 2 == 1) { bad.emplace_back(1); --len; } if (len / 2 <= m) { m -= len / 2; ans += len; } else { ans += m * 2; m = 0; } } ranges::sort(bad, greater()); int rem = 0; for (int len : bad) { if (m > 0) { ++ans; --len; --m; if (len % 2 == 1) { ++rem; --len; } const int tmp = min(len / 2, m); m -= tmp; ans += tmp * 2; } } ans += min(rem, m); cout << ans << '\n'; return 0; }