#include using namespace std; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) int solve(int D, const string &s){ int d = 99; vector v; REP(i,14){ if(s[i] == 'x'){ if(d > 0) d++; else { v.push_back(d); d = +1; } } else { if(d < 0) d--; else { v.push_back(d); d = -1; } } } if(d < 0) v.push_back(d); v.push_back(99); int n = v.size(); if(n == 1) return D; int res = 0; for(int i = 0; i < n; i += 2){ if(v[i] > D){ if(i > 0) res = max(res, -v[i-1]+D); if(i < n-1) res = max(res, -v[i+1]+D); } else { res = max(res, v[i]-v[i-1]-v[i+1]); } } return res; } int main(){ int D; cin >> D; string s,t; cin >> s >> t; s += t; cout << solve(D,s) << endl; return 0; }