(defn input []
  (list
    (Integer/parseInt (read-line))
    (read-line)))

(defn CutAndCount [[N S]]
  (->> (range 1 N)
    (map #(split-at % S))
    (map #(map distinct %))
    (map #(map (partial apply str) %))
    (map (fn [x] (map #(clojure.string/includes? (rest x) (str %)) (first x))))
    (map #(filter identity %))
    (map count)
    (apply max)))

(-> (input)
  CutAndCount
  println)