Scanf.scanf "%d %d" (fun n m -> let s = Array.init n (fun _ -> Scanf.scanf " %s" (fun s -> s)) in let rec loop i j cur mm = if j = m then mm else if i = n then loop 0 (j + 1) 0 (max mm cur) else let cur = if s.(i).[j] = 'x' then cur + 1 else cur in loop (i + 1) j cur mm in Printf.printf "%d\n" @@ 1 + loop 0 0 0 0 )