Class Main
    Public Shared Sub Main()
        Dim N As Integer = Console.ReadLine()
        Dim S As String = Console.ReadLine()
        Dim i1, i2, i3 As Integer
        Dim sum As Long = 0
        For i1 = 0 To N - 1
            For i2 = i1 + 1 To N - 1
                If S.Substring(i1, 1) <> S.Substring(i2, 1) Then
                    For i3 = i2 + 1 To N - 1
                        If i3 - i2 <> i2 - i1 Then
                            If S.Substring(i1, 1) <> S.Substring(i3, 1) And S.Substring(i2, 1) <> S.Substring(i3, 1) Then
                                sum += 1
                            End If
                        End If
            Next
                End If
            Next
        Next
        Console.WriteLine(sum)
    End Sub
End Class