use std::cmp::max; use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let s: Vec = itr.next().unwrap().chars().collect(); let t: Vec = itr.next().unwrap().chars().collect(); let mut week = Vec::new(); for i in 0..7 { week.push(s[i] == 'o'); } for i in 0..7 { week.push(t[i] == 'o'); } let mut ans = 0; for i in 0..14 { let mut cnt = 0; let mut u = week.clone(); let mut j = i; let mut un = false; while j < 14 { if !u[j] { un = true; if cnt == n { break; } cnt += 1; u[j] = true; } else if un { break; } j += 1 } cnt = 0; for j in 0..14 { if u[j] { cnt += 1; } else { ans = std::cmp::max(ans, cnt); cnt = 0; } } ans = std::cmp::max(ans, cnt); } let mut atama = 0; let mut oshiri = 0; let mut idx = 0; while idx < 14 && week[idx] { atama += 1; idx += 1 } week.reverse(); idx = 0; while idx < 14 && week[idx] { oshiri += 1; idx += 1 } println!("{}", max(ans, max(atama + n, oshiri + n))); }