import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val S = sc.next

    val a = ArrayBuffer.fill(N)(0)
    ('a' to 'z').foreach { c =>
      val cc = S.zipWithIndex.filter(_._1 == c).map(_._2)
      if (cc.length >= 2) {
        (cc.head to cc.last).foreach { i => a(i) += 1 }
      }
//      println(a)
    }
    a.max.toString
  }
}
