#include<bits/stdc++.h>
int n,m;
std::map<std::string,int>cnt;
std::string s;
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n;
    std::cin >> s;
    std::vector<int>max_pos(10,-1);
    std::vector<int>min_pos(10,n + 1);
    for(int i = 0; i <= 9; ++i) min_pos[i] = n + 1,max_pos[i] = -1;
    for(int i = 0; i < n; ++i){
        int m = s[i] - '0';
        max_pos[m] = i;
        min_pos[m] = std::min(min_pos[m],i);
    }
    std::vector<int>memo(1000,0LL);
    for(int i = 0; i < n; ++i){
        int key = s[i] - '0';
        for(int l = 0; l <= 9; ++l){
            for(int r = 0; r <= 9; ++r){
                if(max_pos[r] == -1 or min_pos[l] == n + 1)
                    continue;
                if(min_pos[l] < i && i < max_pos[r])
                    memo[l * 100 + key * 10 + r] = 1;
            }
        }
    }
    std::cout << std::count_if(memo.begin(),memo.end(),[](int e){return e > 0;})<< '\n';
}


