N = gets.to_i
S = gets.chomp

ans = 0
(0..999).each do |i|
    t = format('%03d', i)
    l = S.index(t[0])
    r = S.rindex(t[2])
    next if not (l && r)
    (ans += 1) if (S[l+1..[r-1, 0].max]).index t[1]
end
p ans