Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
      for k in range(p2+1,N):
        if n3==int(S[k]):
          count+=1
         # print(n1,n2,n3,S[p1]+S[p2]+S[k])
          cond=0
          break
      
              
print(count)


Fixed submission:
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 for n2 in range(10):
  for n3 in range(10):
   cond=0 
   for i in range(N):
     if cond==0:
       if n1==int(S[i]):
          cond+=1
     elif cond==1:
       if n2==int(S[i]):
          cond+=1
     else:
       if n3==int(S[i]):
        count+=1
        break
      
              
print(count)


Fixed submission:
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 for n2 in range(10):
  for n3 in range(10):
   cond=0 
   for i in range(N-2):
     if cond==1:
      break
     if n1==int(S[i]):
       for j in range(i+1,N-1):
         if cond==1:
          break
         if n2==int(S[j]):
          for k in range(j+1,N):
           if n3==int(S[k]):
             count+=1
             cond=1
             break
              
print(count)


Fixed submission:
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
#print(N,S)

count=0

for n1 in range(10):
 for n2 in range(10):
  string=''
  for i in range(N-2):
    if n1==int(S[i]):
       for j in range(i+1,N-1):
         if n2==int(S[j]):
          #print(n1,n2,S[j+1:])
          string +=S[j+1:]           
  count+=len(set(string))
     
    
print(count)


Fixed submission:
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
#print(N,S)

pins=list()

for i in range(N-1):
  for j in range(i+1,N):
    for k in range(j+1,N):
     pins.append(S[i]+S[j]+S[k])
   #print(set(S[j+1:]))
  
print(len(set(pins)))

Fixed submission:
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)