#include <bits/stdc++.h>
using namespace std;
struct CustomHash {
  template <typename T, typename U>
  std::size_t operator()(const std::pair<T, U> &x) const {
    return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
  }
};
unordered_map<std::pair<int, int>, int, CustomHash> mp;
int n, k, A[200100], D[200100];
int inline count_digits(unsigned long long x) {
  int cnt = 0;
  while (x) x /= 10, cnt++;
  return cnt;
}
int main() {
  scanf("%i%i", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%i", &A[i]), mp[make_pair(D[i] = count_digits(A[i]), A[i] % k)]++;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    mp[make_pair(D[i], A[i] % k)]--;
    for (int p = 1, z = 1; p <= 10; p++, z *= 10) {
      unsigned long long x = (unsigned long long)A[i] * z * 10;
      x = (x + k) % k;
      x = (k - x) % k;
      ans += mp[make_pair(p, (int)x)];
    }
    mp[make_pair(D[i], A[i] % k)]++;
  }
  printf("%I64d\n", ans);
}
