"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function upper_bound(d,a,b,e){for(var c;1<b-a;)d[c=a+b>>1]<=e?a=c:b=c;return d[a]<=e?b:a};

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  var ans = 0;
  var id = xArray("[]",10);
  for(var i = 0; i < n; i++){
    id[s[i]].push(i);
  }
  for(var i = 0; i < 10; i++){
    id[i].push(n);
  }
  for(var i = 0; i < 1000; i++){
    var a = i/100|0;
    var b = Math.floor(i/10)%10;
    var c = i%10;
    var x1 = id[a][0];
    if(x1 === n)continue;
    var x2 = upper_bound(id[b],0,id[b].length,x1);
    x2 = id[b][x2];
    if(x2 === n)continue;
    var x3 = upper_bound(id[c],0,id[c].length,x2);
    x3 = id[c][x3];
    if(x3 === n)continue;
    ans++;
  }
  return ans;
}