#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
long long fast_mod(long long a, long long b) {
  long long tmp = a / b;
  return a - (b * tmp);
}
long long countdigit(long long n) {
  if (!n) return 0;
  return 1 + countdigit(n / 10);
}
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  unordered_map<int, int> m[11];
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    m[countdigit(x)][x % k]++;
    arr[i] = x;
  }
  long long ans = 0;
  long long curr, temp, rem, req, tmp;
  for (long long i = 1; i <= n; i++) {
    curr = arr[i];
    temp = countdigit(curr);
    for (long long j = 1; j <= 10; j++) {
      tmp = (curr * 10) / k;
      curr = curr * 10 - k * tmp;
      req = (k - curr);
      if (req == k) req = 0;
      if (m[j].find(req) != m[j].end()) ans += m[j][req];
      if (temp == j)
        if (arr[i] % k == req) ans--;
    }
  }
  cout << ans;
  return 0;
}
