stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

using ll=long long;



int main()

{

    int n;cin >>n;

    string s;cin >>s;

    string num[1000];

    for(int i=0;i<1000;i++){

        ostringstream ss;

        ss << i;

        num[i]=ss.str();

        string a="00",b="0";

        if(i<10){

            swap(a,num[i]);

            num[i]+=a;

        }

        else if(i<100){

            swap(b,num[i]);

            num[i]+=b;

        }

    }

    ll ans=0;

    for(int i=0;i<1000;i++){

        bool flg=true;int t=0;

        for(int k=0;k<3;k++){

            bool w=true;

            for(int j=t;j<n;j++){

                if(num[i][k]==s[j]&&w){

                    t=j+1;

                    w=false;

                }

            }

            if(w)flg=false;

        }

        if(flg)ans++;

    }

    cout << ans << endl;

    return 0;

}


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



using namespace std;

#define all(a)a.begin(),a.end()

using ll=long long;

const int INF = 1<<30;

const ll INFll =1LL<<62;

const int mod= int(1e9)+7;

using P = pair<ll,ll>;

using ld=long double;



vector<string>ans;

void f(string a){

    if(a.size()==3){

        ans.push_back(a);

        return;

    }

    for (int i = 0; i < 10; ++i) {

        a+=(char)('0'+i);

        f(a);

        a.pop_back();

    }

}



int main(){

    f("");

    ll n;cin >>n;

    string s;cin >>s;

    ll cnt=0;

    for(auto a:ans){

        ll k=0;

        for (int i = 0; i < n; ++i) {

            if(a[k]==s[i]){

                if(k==2){

                    cnt++;

                    break;

                }

                else k++;

            }

        }

    }

    cout <<cnt <<endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

const int INF = (1<<30);

const ll INFLL = (1ll<<60);

const ll MOD = (ll)(1e9+7);



#define l_ength size



void mul_mod(ll& a, ll b){

	a *= b;

	a %= MOD;

}



void add_mod(ll& a, ll b){

	a = (a<MOD)?a:(a-MOD);

	b = (b<MOD)?b:(b-MOD);

	a += b;

	a = (a<MOD)?a:(a-MOD);

}



string s;

bool dp[30303][11][11][11];



int main(void){

	int n,i,p,q,r,ans=0;

	cin >> n;

	cin >> s;

	dp[0][10][10][10] = true;

	for(i=0; i<n; ++i){

		for(p=0; p<11; ++p){

			for(q=0; q<11; ++q){

				for(r=0; r<11; ++r){

					dp[i+1][p][q][r] |= dp[i][p][q][r];

					dp[i+1][q][r][s[i]-'0'] |= dp[i][p][q][r];

				}

			}

		}

	}

		for(p=0; p<10; ++p){

			for(q=0; q<10; ++q){

				for(r=0; r<10; ++r){

					if(dp[n][p][q][r]){

						++ans;

					}

				}

			}

		}

	cout << ans << endl;

	return 0;

}


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

using namespace std;

typedef long long ll;

const int INF = (1<<30);

const ll INFLL = (1ll<<60);

const ll MOD = (ll)(1e9+7);



#define l_ength size



void mul_mod(ll& a, ll b){

	a *= b;

	a %= MOD;

}



void add_mod(ll& a, ll b){

	a = (a<MOD)?a:(a-MOD);

	b = (b<MOD)?b:(b-MOD);

	a += b;

	a = (a<MOD)?a:(a-MOD);

}



string s;

int d[30303][10];

bool ans[10][10][10];



int main(void){

	int n,i,j,k,cnt=0;

	cin >> n;

	cin >> s;

	for(i=0; i<n; ++i){

		s[i] -= '0';

		for(j=0; j<10; ++j){

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

		}

		++d[i+1][s[i]];

	}

	for(i=0; i<n; ++i){

		for(j=0; j<10; ++j){

			for(k=0; k<10; ++k){

				if(d[i][j] && (d[n][k]-d[i+1][k])){

					ans[j][s[i]][k] = true;

				}

			}

		}

	}

	for(i=0; i<10; ++i){

		for(j=0; j<10; ++j){

			for(k=0; k<10; ++k){

				if(ans[i][j][k]){

					++cnt;

				}

			}

		}

	}

	cout << cnt << endl;

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<iomanip>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<functional>

#include<map>

#include<cstdlib>

#include<complex>

#include<numeric>

#include<set>

#include<deque>

#include<queue>



using namespace std;

using Int = long long;

Int INF = 1LL << 60;

const Int MOD = 1000000000 + 7;



template<class T>//ex) auto dp = make_vec(4,4,4,INF);

vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }

template<class... Size>

auto make_vec(size_t s, Size... tail) {

	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));

}





int main() {



	cin.tie(nullptr);

	ios::sync_with_stdio(false);



	Int N;

	cin >> N;



	string S;

	cin >> S;



	auto dp = make_vec(N + 1, 4, 1000, 0);//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1

	dp[0][0][0] = 1;



	for (Int i = 0; i < N; i++) {

		for (Int j = 0; j < 3; j++) {

			for (Int k = 0; k < 100; k++) {

				if (dp[i][j][k]==0) {

					continue;

				}

				//i文字目を選択する場合

				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = 1;

			

				//i文字目を選択しない場合

				dp[i + 1][j][k] = 1;

			}

		}

	}



	Int ans = 0;

	vector<bool> seen(1000,false);

	for (Int i = 1; i <= N; i++) {

		for (Int k = 0; k < 1000; k++) {

			if (dp[i][3][k]) {

				if (seen[k]) {

					continue;

				}

				ans++;

				seen[k] = true;

			}

		}

	}

	cout << ans << "\n";



}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<iomanip>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<functional>

#include<map>

#include<cstdlib>

#include<complex>

#include<numeric>

#include<set>

#include<deque>

#include<queue>



using namespace std;

using Int = long long;

Int INF = 1LL << 60;

const Int MOD = 1000000000 + 7;



template<class T>//ex) auto dp = make_vec(4,4,4,INF);

vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }

template<class... Size>

auto make_vec(size_t s, Size... tail) {

	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));

}





int main() {



	cin.tie(nullptr);

	ios::sync_with_stdio(false);



	Int N;

	cin >> N;



	string S;

	cin >> S;



	auto dp = make_vec(N + 1, 4, 1000, false);//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1

	dp[0][0][0] = 1;



	for (Int i = 0; i < N; i++) {

		for (Int j = 0; j < 3; j++) {

			for (Int k = 0; k < 100; k++) {

				if (!dp[i][j][k]) {

					continue;

				}

				//i文字目を選択する場合

				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = true;

			

				//i文字目を選択しない場合

				dp[i + 1][j][k] = true;

			}

		}

	}



	Int ans = 0;

	vector<bool> seen(1000,false);

	for (Int i = 1; i <= N; i++) {

		for (Int k = 0; k < 1000; k++) {

			if (dp[i][3][k]) {

				if (seen[k]) {

					continue;

				}

				ans++;

				seen[k] = true;

			}

		}

	}

	cout << ans << "\n";



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

#define all(x) (x).begin(), (x).end()



int main() {

    int N;

    string S;

    cin >> N >> S;

    int res = 0;

    rep(a, 0, 10) {

        int a_i = -1;

        rep(i, 0, N-2) {

            if (S[i] == to_string(a)[0]) {

                a_i = i;

                break;

            }

        }

        if (a_i == -1) continue;

        rep(b, 0, 10) {

            int b_i = -1;

            rep(i, a_i+1, N-1) {

                if (S[i] == to_string(b)[0]) {

                    b_i = i;

                    break;

                }

            }

            if (b_i == -1) continue;

            rep(c, 0, 10) {

                rep(i, b_i+1, N) {

                    if (S[i] == to_string(c)[0]) {

                        res++;

                        break;

                    }

                }

            }

        }

    }

    cout << res << endl;

}

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

using namespace std;

using ll = long long;

#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

#define all(x) (x).begin(), (x).end()



int main() {

    int N;

    string S;

    cin >> N >> S;



    int ans = 0;

    rep(i,0,10) {

        int i0 = find(all(S), to_string(i)[0]) - S.begin();

        if (i0 >= N-2) continue;

        rep(j,0,10) {

            int i1 = find(S.begin() + i0 + 1, S.end(), to_string(j)[0]) - S.begin();

            if (i1 >= N-1) continue;

            rep(k,0,10) {

                int i2 = find(S.begin() + i1 + 1, S.end(), to_string(k)[0]) - S.begin();

                if (i2 < N) ans++;

            }

        }

    }



    cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main()

{

  int N;

  cin >> N;

  string S;

  cin >> S;

  int ans = 0;

  for (int i = 0; i < 1000; i++)

  {

    string now = to_string(i);

    int digit1 = 0, digit2 = 0;

    if (i < 10)

    {

      for (int j = 0; j < S.size(); j++)

      {

        if (digit1 == 0 && S[j] == '0')

        {

          digit1++;

          continue;

        }

        if (digit2 == 0 && digit1 > 0 && S[j] == '0')

        {

          digit2++;

          continue;

        }

        if (digit2 > 0 && S[j] == now[0])

        {

          ans++;

          break;

        }

      }

    }

    if (i >= 10 && i < 100)

    {

      for (int j = 0; j < S.size(); j++)

      {

        if (digit1 == 0 && S[j] == '0')

        {

          digit1++;

          continue;

        }

        if (digit2 == 0 && digit1 > 0 && S[j] == now[0])

        {

          digit2++;

          continue;

        }

        if (digit2 > 0 && S[j] == now[1])

        {

          ans++;

          break;

        }

      }

    }

    if (i >= 100)

    {

      for (int j = 0; j < S.size(); j++)

      {

        if (digit1 == 0 && S[j] == now[0])

        {

          digit1++;

          continue;

        }

        if (digit2 == 0 && digit1 > 0 && S[j] == now[1])

        {

          digit2++;

          continue;

        }

        if (digit2 > 0 && S[j] == now[2])

        {

          ans++;

          break;

        }

      }

    }

  }

  cout << ans << endl;

}


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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;

using P = pair<int, int>;



const long long MOD = 1000000007;

const long long INF = 1LL << 60;



int main()

{

  int N;

  string S;

  cin >> N >> S;

  ll ans = 0;

  for (int i = 0; i <= 9; i++)

  {

    for (int j = 0; j <= 9; j++)

    {

      for (int k = 0; k <= 9; k++)

      {

        bool first = false, second = false, third = false;

        for (int l = 0; l < N; l++)

        {

          if (!first && S[l] - '0' == i)

            first = true;

          else if (first && !second && S[l] - '0' == j)

            second = true;

          else if (first && second && !third && S[l] - '0' == k)

            third = true;

        }

        if (first && second && third)

          ans++;

      }

    }

  }

  cout << ans << endl;

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

typedef long long ll;

const int INF = 1e9;

using namespace std;



int main(){

    int n;

    string s;

    cin >> n >> s;

    int num = 0;

    for (int i = 0; i < 10; ++i) {

       for (int j = 0; j < 10; ++j) {

            for (int k = 0; k < 10; ++k) {

                size_t si = s.find(to_string(i));

                if(si == string::npos){

                    continue;

                }

                size_t sj = s.find(to_string(j), si+1);

                if(sj == string::npos){

                    continue;

                }

                size_t sk = s.find(to_string(k), sj+1);

                if(sk == string::npos){

                    continue;

                }

                else{

                    num++;

                }

            }

        }

    }

    cout << num << endl;

}


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

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;



int main(){

    int n;

    string s;

    cin >> n >> s;

    int res = 0;

    for (int i = 0; i < 10; ++i) {

        int iid = s.find(to_string(i));

        if (iid == string::npos) continue;



        for (int j = 0; j < 10; ++j) {

            string sj = s.substr(iid + 1);

            int jid = sj.find(to_string(j));

            if (jid == sj.length() - 1) continue;

            if (jid == string::npos) continue;



            for (int k = 0; k < 10; ++k) {

                string sk = sj.substr(jid + 1);

                int kid = sk.find(to_string(k));

                if (kid != string::npos){

                    res++;

                }

            }

        }

    }

    cout << res << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)



int main(){

    set<string> x,y,z;

    int N;

    string S;

    cin >> N >> S;

    FOR(i,0,S.size()){

        string a = "2";

        a[0] = S[i];

        for(auto b:y){

            z.insert(b+a);

        }

        for(auto b:x){

            y.insert(b+a);

        }

        x.insert(a);

    }

    cout << z.size() << endl;

}

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

using namespace std;

typedef long long ll;

#define P pair<ll,ll>

#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)

#define TO(x,t,f) ((x)?(t):(f))

#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9

#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted

#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted

#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted

#define REV(x) (reverse(x.begin(),x.end())) //reverse

ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}

ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}

#define NEXTP(x) next_permutation(x.begin(),x.end())

const ll INF=ll(1e16)+ll(7);

const ll MOD=1000000007LL;

#define out(a) cout<<fixed<<setprecision((a))

//tie(a,b,c) = make_tuple(10,9,87);

#define pop_(a) __builtin_popcount((a))

ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}





int main(){



  int N;

  string s;

  cin >> N >> s;

  bool ok1[10]={},ok2[10][10]={},ok3[10][10][10]={};

  for(auto c:s){

    FOR(i,0,10)FOR(j,0,10)ok3[i][j][c-'0'] |= ok2[i][j];

    FOR(i,0,10)ok2[i][c-'0'] |= ok1[i];

    ok1[c-'0'] = true;

  }

  ll ans = 0;

  FOR(i,0,10)FOR(j,0,10)FOR(k,0,10){

    ans += ok3[i][j][k];

  }

  cout << ans << endl;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

//const ll MOD = 1e9 + 7;

//const ll MOD = 998244353;

//const ll MOD = ;

ll mod(ll A, ll M) {return (A % M + M) % M;}

const ll INF = 1LL << 60;

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

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

ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}

ll myctoi(char C) {return C - '0';}

char myitoc(ll N) {return '0' + N;}

#define FINALANS(A) {cout << (A) << '\n'; exit(0);}



int main()

{

  ll N;

  cin >> N;

  string S;

  cin >> S;



  vector<vector<bool>> dp(1001, vector<bool>(4, false));

  dp.at(0).at(0) = true;

  for (ll i = 0; i < N; i++)

  {

    ll x = myctoi(S.at(i));

    for (ll j = 1000; j >= 0; j--)

    {

      for (ll k = 2; k >= 0; k--)

      {

        if (!dp.at(j).at(k))

          continue;

        dp.at(j * 10 + x).at(k + 1) = true;

        //cerr << j << " " << k << endl;

      }

    }

  }



  ll ans = 0;

  for (ll i = 0; i < 1001; i++)

  {

    if (dp.at(i).at(3))

    {

      //cerr << i << endl;

      ans++;

    }

  }

  cout << ans << endl;

}

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

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

//const ll MOD = 998244353;

//const ll MOD = ;

ll mod(ll A, ll M) {return (A % M + M) % M;}

const ll INF = 1LL << 60;

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

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

ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}

ll myctoi(char C) {return C - '0';}

char myitoc(ll N) {return '0' + N;}

#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)



int main()

{

  ll N;

  cin >> N;

  string S;

  cin >> S;



  ll ans = 0;

  for (char c1 = '0'; c1 <= '9'; c1++)

  {

    for (char c2 = '0'; c2 <= '9'; c2++)

    {

      for (char c3 = '0'; c3 <= '9'; c3++)

      {

        vector<char> x = {c1, c2, c3};



        ll cnt = 0;

        for (ll i = 0; i < N; i++)

        {

          if (S.at(i) == x.at(cnt))

          {

            cnt++;

            if (cnt == 3)

            {

              ans++;

              break;

            }

          }

        }

      }

    }

  }

  

  cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <iostream>



using namespace std;



typedef long long ll;



int main() {

    map<string, bool> A1, A2, A3;



    int N;

    cin >> N;

    string S;

    cin >> S;



    A1[S.substr(N-1, 1)] = true;

    A1[S.substr(N-2, 1)] = true;

    A2[S.substr(N-2)] = true;

    for (int i = N - 3; i >= 0; i--) {

        for (auto const& e : A2) {

            string s = S.substr(i, 1);

            s += e.first;

            A3[s] = true;

        }



        for (auto const& e : A1) {

            string s = S.substr(i, 1);

            s += e.first;

            A2[s] = true;

        }



        A1[S.substr(i, 1)] = true;

    }

    

    cout << A3.size() << endl;

}

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

#include <iostream>



using namespace std;



typedef long long ll;



int main() {

    int N;

    cin >> N;

    string S;

    cin >> S;



    int cnt = 0;

    for (char i = '0'; i <= '9'; i++) {

        size_t pi = S.find(i);

        if (pi == string::npos) { continue; }



        for (char j = '0'; j <= '9'; j++) {

            size_t pj = S.find(j, pi+1);

            if (pj == string::npos) { continue; }



            for (char k = '0'; k <= '9'; k++) {

                size_t pk = S.find(k, pj+1);

                if (pk == string::npos) { continue; }



                cnt++;

            }

        }

    }



    cout << cnt << endl;



    /*

    int cnt = 0;

    for (int i = 0; i < 1000; i++) {

        int c[3] = { i / 100, (i % 100) / 10, i % 10};

        int p = 0;

        for (int j = 0; j < N; j++) {

            if (S[j] == ('0' + c[p])) {

                p++;

            }

            if (p == 3) {

                cnt++;

                break;

            }

        }

    }



    cout << cnt << endl;

    */

/*

    map<string, bool> A1, A2, A3;

    A1[S.substr(N-1, 1)] = true;

    A1[S.substr(N-2, 1)] = true;

    A2[S.substr(N-2)] = true;

    for (int i = N - 3; i >= 0; i--) {

        for (auto const& e : A2) {

            string s = S.substr(i, 1);

            s += e.first;

            A3[s] = true;

        }



        for (auto const& e : A1) {

            string s = S.substr(i, 1);

            s += e.first;

            A2[s] = true;

        }



        A1[S.substr(i, 1)] = true;

    }

    

    cout << A3.size() << endl;

*/    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<math.h>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<assert.h>

#include<numeric>

using namespace std;

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

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

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;



int main(){

    int n;cin>>n;

    string s;

    cin>>s;

    int ans = 0;

    rep(i,10)rep(j,10)rep(k,10){

        vector<char> v = {char('0'+i),char('0'+j),char('0'+k),'-'};

        int c=0;

        rep(l,n){

            if(s[l]==v[c])c++;

        }

        ans += c==3;

    }

    cout<<ans<<endl;

    return 0;

}

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





int main(){

	int n;

	char str[50010];

	int x = 0;

	int ctr = 0;

	scanf("%d", &n);

	scanf("%s", str);



for(int i = 0;i < 10;i++){

	for(int j = 0;j<10;j++){

		for(int k = 0;k<10;k++){

			char test[] = {i,j,k};

		    x = 0;

			for(int a = 0;a <n;a++){

				if(str[a] - '0' == test[x]){

					x++;

				}

				if(x == 3){

					ctr++;

					break;

				}

			}

			

		}

	}

}

printf("%d", ctr);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>

#include <algorithm>

#include <vector>

#include <string>

const long long mod = 1000000007;

 

 

int main() {

	int N;

	scanf("%d", &N);

	char*S = new char[N + 1];

	scanf("%s", S);

	int cnt = 0;

	for (char s1 = '0'; s1 <= '9'; s1++) {

		int p1 = 0;

		for (; p1 < N; p1++) {

			if (S[p1] == s1)break;

		}

		p1++;

		if (p1 == N)continue;

		for (char s2 = '0'; s2 <= '9'; s2++) {

			int p2 = p1;

			for (; p2 < N; p2++) {

				if (S[p2] == s2)break;

			}

			p2++;

			if (p2 == N)continue;

			for (char s3 = '0'; s3 <= '9'; s3++) {

				int p3 = p2;

				for (; p3 < N; p3++) {

					if (S[p3] == s3) {

						cnt++;

						break;

					}

				}

				p3++;

				if (p3 == N)continue;

 

			}

		}

	}

	printf("%d", cnt);

	return 0;

}

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





int main(){

	int n;

	char str[50010];

	int x = 0;

	int ctr = 0;

	scanf("%d", &n);

	scanf("%s", str);



for(int i = 0;i < 10;i++){

	for(int j = 0;j<10;j++){

		for(int k = 0;k<10;k++){

			char test[] = {i,j,k};

		    x = 0;

			for(int a = 0;a <n;a++){

				if(str[a] - '0' == test[x]){

					x++;

				}

				if(x == 3){

					ctr++;

					break;

				}

			}

			

		}

	}

}

printf("%d", ctr);

	return 0;

}

// Fastest known solution for this problem: