import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto S = sread();
    auto count = new long[][](N + 1, 10);
    foreach (i; 1 .. N + 1)
    {
        count[i - 1][S[i - 1] - '0'] += 1;
        count[i][] = count[i - 1][];
    }
    long ans;
    bool[10] visited1;
    foreach (i; 0 .. S.length)
        if (!visited1[S[i] - '0'])
        {
            long a = S[i] - '0';
            // writeln(a);
            visited1[a] = true;
            bool[10] visited2;
            foreach (j; i + 1 .. S.length)
                if (!visited2[S[j] - '0'])
                {
                    long b = S[j] - '0';
                    // writeln("b", b);
                    visited2[b] = true;
                    foreach (x; 0 .. 10)
                    {
                        if (0 < count[$ - 1][x] - count[j][x])
                        {
                            // writeln(a, b, x);
                            ans++;
                        }
                    }
                }
        }
    writeln(ans);
}
