#include <bits/stdc++.h>
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  std::vector<int> a(n);
  for (int& x : a) {
    scanf("%d", &x);
  }
  std::vector<int> len(n);
  for (int i = 0; i < n; i++) {
    len[i] = std::to_string(a[i]).size();
  }
  std::vector<unsigned long long> p10(11);
  p10[0] = 1;
  for (int i = 1; i < (int)p10.size(); i++) {
    p10[i] = p10[i - 1] * 10;
  }
  std::vector<std::map<int, int>> c(11);
  for (int i = 1; i <= 10; i++) {
    for (int j = 0; j < n; j++) {
      int r = int((p10[i] * a[j]) % k);
      auto it = c[i].find(r);
      if (it != c[i].end()) {
        it->second++;
      } else {
        c[i].insert(std::pair<int, int>(r, 1));
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int cr = a[i] % k;
    int rr = (cr == 0) ? 0 : k - cr;
    auto it = c[len[i]].find(rr);
    ans += it == c[len[i]].end() ? 0 : it->second;
    if (int((p10[len[i]] * a[i]) % k) == rr) {
      ans--;
    }
  }
  printf("%I64d", ans);
  return 0;
}
