#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int calc(const vector &b) { int ret = 0; for (int i = 0; i < b.size(); i++) { if (!b[i]) continue; int j = i; while (j < b.size() && b[j]) { ++j; } ret = max(ret, j - i); i = j-1; } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int d; cin >> d; vector b(14 * 3); string s1, s2; cin >> s1 >> s2; string s = s1 + s2; REP (i, 14) { if (s[i] == 'o') b[14 + i] = true; } int ret = calc(b); for (int i = 0; i + d - 1 < 14 * 3; i++) { vector x = b; for (int j = i; j < i + d; j++) { if (x[j]) break; x[j] = true; ret = max(ret, calc(x)); } } cout << ret << endl; return 0; }