#include int note[16]; int main(void) { int d; char c[15]; scanf("%d%s%s", &d, c, &c[7]); c[14] = 'x'; int kinou = 'x', cnt = 0; note[0] = 15; int i; for(i = 0; i < 15; i++) { if(kinou != c[i]) { cnt++; } note[cnt]++; kinou = c[i]; } note[cnt] += 15; int max = d; for(i = 1; i <= cnt - 1; i += 2) { // ここミスってた... int len; len = note[i] + ( (note[i - 1] <= d) ? (note[i - 1] + note[i - 2]) : d ); if(max < len) { max = len; } len = note[i] + ( (note[i + 1] <= d) ? (note[i + 1] + note[i + 2]) : d ); if(max < len) { max = len; } } printf("%d\n", max); return 0; }