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; while j < 14 { if !u[j] { if cnt == n { break; } cnt += 1; u[j] = true; } 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); } println!("{}", ans); }