#include <bits/stdc++.h>
using namespace std;
const long long mos = 0x7FFFFFFF;
const long long nmos = 0x80000000;
const int inf = 0x3f3f3f3f;
const long long inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double esp = 1e-8;
const double PI = acos(-1.0);
template <typename T>
inline T read(T& x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = f ? -x : x;
}
const int maxn = 2e5 + 9;
long long a[maxn], lo[maxn];
map<long long, long long> mp[11];
long long n, k;
int main() {
  scanf("%I64d%I64d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    long long tmp = 1ll * a[i], len = 0;
    while (tmp > 0) {
      tmp /= 10;
      len++;
    }
    lo[i] = len;
    mp[len][a[i] % k]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long tmp = 1ll * a[i];
    for (int j = 1; j <= 10; j++) {
      tmp = (tmp * 10ll) % k;
      long long c = (k - tmp);
      if (c >= k) c = c % k;
      auto po = mp[j].find(c);
      if (po != mp[j].end()) ans += po->second;
      if (lo[i] == j && a[i] % k == c) ans--;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
