open System.Collections.Generic

let getV (d:Dictionary<_,_>) k =
    match d.TryGetValue(k) with
    | true, n -> n+1
    | _ -> 1

let init (d:Dictionary<_,_>) =
    seq { for _ in 1..(stdin.ReadLine() |> int) -> stdin.ReadLine().Length }
    |> Seq.iter (fun k -> d.[k] <- getV d k)

let pred a b =
    if (snd a)=(snd b) && (fst a)<(fst b) || (snd a)<(snd b) then b else a

let f () =
    let d = Dictionary<int,int>()
    init d |> ignore
    seq { for e in d -> (e.Key,e.Value) }
    |> Seq.fold (fun a e -> pred a e) (0,0)
    |> fun e -> fst e - 2

f () |> printfn "%A"