program puslapiavimas;
  var f: text;
      N, K, i, pavardes, raides, max, puslapiai: integer;
      s: string;
      M: array ['a'..'z'] of integer;
      c: char;
begin
  assign(f, 'puslap.in');
  reset(f);
  readln(f, N, K);
  fillchar(M, sizeof(M), 0);
  for i := 1 to N do
    begin
      readln(f, s);
      inc(M[s[1]])
    end;
  close(f);
  pavardes := 0;
  raides := 0;
  max := 0;
  puslapiai := 0;
  for c := 'a' to 'z' do
    begin
      pavardes := pavardes + M[c];
      if M[c] > 0 then inc(raides);
      if pavardes >= K
        then
          begin
            if raides > max
              then
                begin
                  max := raides;
                end;
            puslapiai := puslapiai + pavardes div K;
            pavardes := pavardes mod K;
            if pavardes <> 0
              then raides := 1
              else raides := 0
          end
    end;
  if raides > max
    then
      begin
        max := raides;
      end;
  assign(f, 'puslap.out');
  rewrite(f);
  writeln(f, max);
  close(f)
end.
