#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[11];
const int maxn = 2 * 1e5 + 10;
int a[maxn];
int get(int x) {
  int num = 0;
  while (x) {
    num++;
    x /= 10;
  }
  return num;
}
int main() {
  int n, k;
  long long ans = 0;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &(a[i]));
  for (int i = 1; i <= 10; ++i) mp[i].clear();
  for (int i = 1; i <= n; ++i) {
    long long x = a[i] % k, tmp = 10 % k;
    for (int j = 1; j <= 10; ++j) ++mp[j][x * tmp % k], x = x * tmp % k;
  }
  for (int i = 1; i <= n; ++i) {
    long long tmp = (k - a[i] % k) % k, tmpp = a[i] % k, tmppp = 10 % k;
    int len = get(a[i]);
    ans += mp[len][tmp];
    for (int j = 1; j <= len; ++j) tmpp = tmpp * tmppp % k;
    if (tmpp == tmp) --ans;
  }
  printf("%lld\n", ans);
  return 0;
}
