n,k=map(int,input().split()) b=list(map(int,input().split())) sum_k=0 for num in b: if num // 10 % 10 == k: sum_k+=num print(sum_k)