//space complexity :- O(n)
//time complexity :- O(max(length of input int , n))
#include <bits/stdc++.h>
using namespace std;
int f(vector<int>& v , int k)
{
map<int , int> m;
for(int x : v)
m[x]++;
int ans = 0;
int l = 10;
while(k / l > 0)
{
int a = k%l;
int b = k/l;
if(m.find(a) == m.end() || m.find(b) == m.end())
{
l = l*10;
continue ;
}
if(a == b)
ans = ans + m[a]*(m[a] - 1);
else
ans = ans + m[a]*m[b];
l = l*10;
}
return ans;
}
int main()
{
int n;
cin>>n;
int x;
cin>>x;
vector<int> v(n);
for(int i = 0 ; i < n ; i++)
{
cin>>v[i];
}
cout<<f(v , x);
return 0;
}