#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


  
int findSubsequenceCount(string S, string T) 
{ 
    int m = T.length(), n = S.length(); 
  
    // T can't appear as a subsequence in S 
    if (m > n) 
        return 0; 
  
    // mat[i][j] stores the count of occurrences of 
    // T(1..i) in S(1..j). 
    int mat[m + 1][n + 1]; 
  
    // Initializing first column with all 0s. An empty 
    // string can't have another string as suhsequence 
    for (int i = 1; i <= m; i++) 
        mat[i][0] = 0; 
  
    // Initializing first row with all 1s. An empty 
    // string is subsequence of all. 
    for (int j = 0; j <= n; j++) 
        mat[0][j] = 1; 
  
    // Fill mat[][] in bottom up manner 
    for (int i = 1; i <= m; i++) { 
        for (int j = 1; j <= n; j++) { 
            // If last characters don't match, then value 
            // is same as the value without last character 
            // in S. 
            if (T[i - 1] != S[j - 1]) 
                mat[i][j] = mat[i][j - 1]; 
  
            // Else value is obtained considering two cases. 
            // a) All substrings without last character in S 
            // b) All substrings without last characters in 
            // both. 
            else
                mat[i][j] = mat[i][j - 1] + mat[i - 1][j - 1]; 
        } 
    } 
  
    /* uncomment this to print matrix mat 
    for (int i = 1; i <= m; i++, cout << endl) 
        for (int j = 1; j <= n; j++) 
            cout << mat[i][j] << " ";  */
    return mat[m][n]; 
} 
  
// Driver code to check above method 
int main() { 
    int ans = 0;
    int N; string S; cin >> N >> S;
    rep(i,10) rep(j,10) rep(k,10) {
        string T = to_string(i) + to_string(j) + to_string(k);
        //cout << T << endl;
        if(findSubsequenceCount(S, T) != 0) {
            ans++;
        }
    }

    cout << ans << endl; 
    return 0; 
} 

Measured memory_bytes: 768