include [HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
define inf 0x3f3f3f3f
typedef long long ll;
typedef pair[HTML_REMOVED] P;
define pi 3.141592653589793238
int mov[4][2]= {{-1,0},{0,1},{1,0},{0,-1}};
int month[13]= {0,31,0,31,30,31,30,31,31,30,31,30,31};
const int N=100100;
const int Mod=1e9+7;
int arr1[12][N];//低位
int arr2[12][N];//高位
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n,k;
string s;
while(cin>>n>>k){
ll res=0;
while(n--){
cin>>s;
int len=s.length();
stringstream ss(s);
ll x,t;
ss>>x;
t=x;
ll mod=k-x%k;
if(mod==k){
mod=0;
}
res+=arr2[len][mod];
for(int i=1;i<=10;i++){
mod=x%k;
int j=i;
while(mod&&j--){
mod=(mod*10)%k;
}
arr2[i][mod]++;
mod=mod==0?0:(k-mod);
res+=arr1[i][mod];
}
arr1[len][x%k]++;
}
cout<<res<<endl;
}
return 0;
}