// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

 

using ll = long long;

using ld = long double;

#define FOR(i, m, n) for (int i = (m); i < (n); i++)

#define FORR(i, m, n) for (int i = (m); i >= (n); i--)

#define REP(i, n) FOR(i, 0, (n))

#define REPR(i, n) FORR(i, (n) - 1, 0)

#define REP1(i, n) FOR(i, 1, (n) + 1)

#define REPS(c, s) for (char c : s)

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

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

#define REV(c) reverse(ALL(c))

#define sz(v) (int)v.size()

#define endl '\n'

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}

template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}

const int MOD = 1000000007;

const int INF = 1000000001;

const ll LINF = 1000000001000000001LL;

 

void solve();

 

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout << fixed << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;

}



void solve() {

    int n;

    string s;

    cin >> n >> s;

    vector<vector<int>> sum(n + 1, vector<int>(10, 0));

    REP(i, n) {

        REP(j, 10) {

            if (s[i] == (char)('0' + j)) {

                sum[i + 1][j] = sum[i][j] + 1;

            } else {

                sum[i + 1][j] = sum[i][j];

            }

        }

    }



    set<string> ans;



    FOR(i, 1, n - 1) {

        REP(j, 10) {

            if (sum[i][j] == 0) continue;

            REP(k, 10) {

                if (sum[n][k] - sum[i + 1][k] == 0) continue;

                string str;

                str = str + (char)('0' + j) + s[i] + (char)('0' + k);

                ans.emplace(str);

            }

        }

    }

    cout << sz(ans) << endl;

}




// Faster C++ solution for the same problem (measured speedup: 1.1338275559246003x):
#include <bits/stdc++.h>

using namespace std;

 

using ll = long long;

using ld = long double;

using vi = vector<int>;

using vvi = vector<vector<int>>;

using vl = vector<ll>;

using vvl = vector<vector<ll>>;

#define FOR(i, m, n) for (int i = (m); i < (n); i++)

#define FORR(i, m, n) for (int i = (m); i >= (n); i--)

#define REP(i, n) FOR(i, 0, (n))

#define REPR(i, n) FORR(i, (n) - 1, 0)

#define REP1(i, n) FOR(i, 1, (n) + 1)

#define REPS(c, s) for (char c : s)

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

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

#define REV(c) reverse(ALL(c))

#define sz(v) (int)v.size()

#define endl '\n'

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}

template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}

template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}

template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}

template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}

const int MOD = 1000000007;

const int INF = 1000000001;

const ll LINF = 1000000001000000001LL;

 

void solve();

 

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout << fixed << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;

}



void solve() {

    int n;

    string s;

    cin >> n >> s;



    int ans = 0;

    REP(i, 10) {

        char c = i + '0';

        vector<bool> b(10, false);

        vvi v(10, vi(10));

        REP(j, n) {

            if (c == s[j]) {

                FOR(k, j + 1, n) {

                    char q = s[k];

                    int d = (int)(q - '0');

                    REP(l, 10) {

                        if (b[l]) {

                            v[l][d] = 1;

                        }

                    }

                    b[d] = true;

                }

                break;

            }

        }

        // printvv(v);

        REP(x, 10) REP(y, 10) ans += v[x][y];

    }

    cout << ans << endl;

}