stdin.ReadLine()
|> ignore
|> fun () -> stdin.ReadLine()
|> fun s ->
  [0..(s.Length - 1)]
  |> Seq.fold (fun m i ->
    match Map.tryFind s.[i] m with
    | Some _ -> m
    | _ ->
      m.Add (
        s.[i],
        s.[(i + 1)..] |> (
          fun s ->
            [0..(s.Length - 1)]
            |> Seq.fold (fun m i ->
              match Map.tryFind s.[i] m with
              | Some _ -> m
              | _ ->
                m.Add (
                  s.[i],
                  s.[(i + 1)..]
                  |> Seq.distinct
                  |> Seq.length
                )
            ) Map.empty
            |> Seq.sumBy (fun x -> x.Value)
        )
      )
  ) Map.empty
  |> Seq.sumBy (fun x -> x.Value)
|> printfn "%d"
