#include #define rep(i, n) for (int i = 0; i < (n); i++) #define fr(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; typedef pair P; class RLE { public: vector

encode(vector v) { vector

res; P p(v[0], 1); for (int i = 1; i < v.size(); i++) { if (p.first == v[i]) { p.second++; } else { res.push_back(p); p = make_pair(v[i], 1); } } res.push_back(p); return res; } }; int main() { string s[2]; int D; cin >> D; cin >> s[0] >> s[1]; string w = s[0] + s[1]; RLE rle; vector u; rep (i, 14) { u.push_back(w[i] == 'o'); } vector

v = rle.encode(u); int ans = 0; for (int i = 0; i < v.size(); i++) { if (v[i].first == 0) { int DD = min(v[i].second, D); int temp = DD; int temp2 = DD; if (v[i].second == DD && i + 1 < v.size()) { temp += v[i + 1].second; } if (v[i].second == DD && i - 1 >= 0) { temp2 += v[i - 1].second; } if (i - 1 >= 0) { temp += v[i - 1].second; } if (i + 1 < v.size()) { temp2 += v[i + 1].second; } ans = max(ans, temp); ans = max(ans, temp2); } } cout << ans << endl; }