#include <bits/stdc++.h>
using namespace std;
long long pw[100];
int a[200005];
map<int, int> mp[15];
inline int cnt(int x) {
  int rtn = 0;
  while (x) {
    ++rtn, x /= 10;
  }
  return rtn;
}
int main(int argc, char** argv) {
  pw[0] = 1;
  for (int i = 1; i <= 15; i++) pw[i] = pw[i - 1] * 10;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), mp[cnt(a[i])][a[i] % k]++;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      int x = (long long)a[i] * (pw[j] % k) % k;
      x = k - x, x %= k;
      ans += mp[j][x];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (((long long)a[i] % k * (pw[cnt(a[i])] % k) % k + a[i]) % k == 0) --ans;
  }
  cout << ans;
  return 0;
}
