#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define vii                                       vector<int> 
#define vpii                                      vector< pii >

#define mii                                       map< int, int >
#define msi                                       map< string, int > 
#define mib                                       map< int, bool > 

#define all(v)                                    v.begin(),v.end()
#define mset(a,f)                                 memset(a,f,sizeof(a))
#define M                                         1000000007
#define Think_Twice_Code_Once                     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)



#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP();

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7;
int n, Q;
pii a[N];
string s;


void solve()
{
      cin >> n >> s;
      int mask = 0;

      vector< set<int> > vec(10);
      lop(i,0,n)
      {
            int x = s[i] - '0';
            vec[x].insert(i);
      }

      int res = 0;
      lop(i,0,10)
      {
            lop(j,0,10)
            {
                  lop(k,0,10)
                  {
                        if( vec[i].size() == 0 || vec[j].size() == 0 || vec[k].size() == 0) continue;
                        int f = *( vec[i].begin() );
                        int l = *( vec[k].rbegin() );
                        auto it = vec[j].lower_bound(f);
                        int m = 1e10;
                        if( *it == f ) it++;
                        if( it != vec[j].end() ) m = *it;

                        if( f < m and m < l ) res ++;
                  }
            }
      }

      cout << res << endl;



}


int32_t main()
{


      Think_Twice_Code_Once;
 
      int t = 1;
      //cin >> t;
      while(t--) solve();


}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 1664