import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.PrimitiveIterator; import java.util.Scanner; import java.util.function.Supplier; import java.util.stream.IntStream; import java.util.stream.Stream; public class Main{ static Scanner s=new Scanner(System.in); void solve(){ Map m=new HashMap<>(); for(String v:strs(gInt())) m.merge(v.length(),1,Integer::sum); System.out.println( m.entrySet().stream() .max(Entry.comparingByValue().thenComparing(Entry.comparingByKey())) .get().getKey()-2 ); } public static void main(String[] A){ new Main().solve(); } static int gInt(){ return Integer.parseInt(s.next()); } static long gLong(){ return Long.parseLong(s.next()); } static double gDouble(){ return Double.parseDouble(s.next()); } SupplyingIterator ints(int n){ return new SupplyingIterator<>(n,Main::gInt); } SupplyingIterator longs(int n){ return new SupplyingIterator<>(n,Main::gLong); } SupplyingIterator doubles(int n){ return new SupplyingIterator<>(n,Main::gDouble); } SupplyingIterator strs(int n){ return new SupplyingIterator<>(n,s::next); } Range rep(int i){ return Range.rep(i); } Range rep(int f,int t,int d){ return Range.rep(f,t,d); } Range rep(int f,int t){ return rep(f,t,1); } Range rrep(int f,int t){ return rep(t,f,-1); } IntStream REP(int v){ return IntStream.range(0,v); } IntStream REP(int l,int r){ return IntStream.rangeClosed(l,r); } IntStream INTS(int n){ return IntStream.generate(Main::gInt).limit(n); } Stream STRS(int n){ return Stream.generate(s::next).limit(n); } } class SupplyingIterator implements Iterable,Iterator{ int t; Supplier supplier; SupplyingIterator(int t,Supplier supplier){ this.t=t; this.supplier=supplier; } @Override public Iterator iterator(){ return this; } @Override public boolean hasNext(){ return t>0; } @Override public T next(){ --t; return supplier.get(); } } class Range implements Iterable,PrimitiveIterator.OfInt{ int to,cur,d; Range(int from,int to,int d){ this.cur=from-d; this.to=to; this.d=d; } Range(int n){ this(0,n-1,1); } @Override public Iterator iterator(){ return this; } @Override public boolean hasNext(){ return cur+d==to||(cur!=to&&(cur