// Original C++ solution (slower):
#include <bits/stdc++.h>



#define TYPE(c)   remove_reference_t<decltype(c)>

#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)

#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)

#define ALL(c)    c.begin(), c.end()

#define SORT(c)   sort(ALL(c))

#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())

#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())



using namespace std;

using ll = long long;



constexpr int MOD  = (int)1e9 + 7;

constexpr int INF  = (int)1e9 + 1;

constexpr ll  LINF = (ll)1e18 + 1;

template<typename T> constexpr bool chmax(T& a, const T& b)

{ if(a < b) { a = b; return true; } else { return false; } }

template<typename T> constexpr bool chmin(T& a, const T& b)

{ if(b < a) { a = b; return true; } else { return false; } }

template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)

{ return os << "(" << p.first << "," << p.second << ")"; }

ostream& operator<<(ostream &os, const string& s)

{ FOR(v, s) os << *v; return os; }

template<typename T> auto operator<<(ostream& os, const T& t)

    -> typename conditional<true, ostream&, decltype(*t.begin())>::type

{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int N;

    std::cin >> N;

    string S;

    std::cin >> S;



    vector<vector<int>> dp(N, vector<int>(10, -1));

    REP(i, S.size()) {

        if(i != 0) {

            REP(j, 10) {

                dp[N - i - 1][j] = dp[N - i][j];

            }

        }

        dp[N - i - 1][(S[N - i - 1] - '0')] = N - i - 1;

    }



    set<string> ans_set;

    REP(i, N - 2) {

        REP(j, 10) {

            if(dp[i + 1][j] == -1 || dp[i + 1][j] <= i) continue;

            REP(k, 10) {

                if(dp[i + 1][j] == N - 1 ||

                   dp[dp[i + 1][j] + 1][k] == -1 ||

                   dp[dp[i + 1][j] + 1][k] <= dp[i + 1][j]) continue;

                char ss = '0' + j;

                char s  = '0' + k;

                ans_set.emplace(string{S[i], ss, s});

           }

        }

    }

    std::cout << ans_set.size() << std::endl;



    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



#define TYPE(c)   remove_reference_t<decltype(c)>

#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)

#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)

#define ALL(c)    c.begin(), c.end()

#define SORT(c)   sort(ALL(c))

#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())

#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())



using namespace std;

using ll = long long;



constexpr int MOD  = (int)1e9 + 7;

constexpr int INF  = (int)1e9 + 1;

constexpr ll  LINF = (ll)1e18 + 1;

template<typename T> constexpr bool chmax(T& a, const T& b)

{ if(a < b) { a = b; return true; } else { return false; } }

template<typename T> constexpr bool chmin(T& a, const T& b)

{ if(b < a) { a = b; return true; } else { return false; } }

template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)

{ return os << "(" << p.first << "," << p.second << ")"; }

ostream& operator<<(ostream &os, const string& s)

{ FOR(v, s) os << *v; return os; }

template<typename T> auto operator<<(ostream& os, const T& t)

    -> typename conditional<true, ostream&, decltype(*t.begin())>::type

{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int N;

    std::cin >> N;

    string S;

    std::cin >> S;



    vector<vector<int>> dp(N, vector<int>(10, -1));

    REP(i, S.size()) {

        if(i != 0) {

            REP(j, 10) {

                dp[N - i - 1][j] = dp[N - i][j];

            }

        }

        dp[N - i - 1][(S[N - i - 1] - '0')] = N - i - 1;

    }



    ll ans = 0;

    REP(i, 10) {

        auto ii = dp[0][i];

        if(ii == -1 || ii == N - 1) continue;

        REP(j, 10) {

            auto ji = dp[ii + 1][j];

            if(ji == -1 || ji <= ii || ji == N - 1) continue;

            REP(k, 10) {

                auto ki = dp[ji + 1][k];

                if(ki == -1 || ki <= ji) continue;

                ans++;

            }

        }

    }

    std::cout << ans << std::endl;



    return 0;

}


// Fastest known solution for this problem: