program lucky_pin
  implicit none
  integer :: n, i, a(0:30000,0:9) = -1, m = 0, x, d0, d1, d2
  character(30000) :: s
  read(*,*) n
  read(*,*) s
  do i = n-1, 0, -1
    a(i,:) = a(i+1,:)
    x = ord(s(i+1:i+1))
    a(i,x) = i+1
  end do
  do i = 0, 999
    d0 = mod(i,10)
    d1 = mod(i,100)/10
    d2 = i/100
    x = a(0,d2)
    if (x < 0) cycle
    x = a(x,d1)
    if (x < 0) cycle
    x = a(x,d0)
    if (x < 0) cycle
    m = m+1
  end do
  write(*,'(i0)') m
contains
  integer function ord(s)
    character(1), intent(in) :: s
    ord = ichar(s)-48
  end
end program lucky_pin