#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5+10;
int n,m;
int a[N],s[11][N];
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=0;i<n;i++){
int t = a[i]%m;
for(int j=0;j<11;j++){
s[j][t]++;
t = t*10 % m;
}
}
LL res = 0;
for(int i=0;i<n;i++){
LL t = a[i] % m;
int len = to_string(a[i]).size();
res += s[len][(m-t)%m];
LL r = t;
while(len--) r=r*10 % m;
if(r==(m-t)%m) res--;
}
printf("%lld",res);
}
07-18
765
09-24
242
07-13