#include <bits/stdc++.h>
int digits(int n) {
  int r = 0;
  while (n > 0) {
    n = n / 10;
    ++r;
  }
  return r;
}
int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> data(n);
  for (auto& e : data) {
    std::cin >> e;
  }
  std::unordered_map<int, int[11]> index;
  for (uint64_t e : data) {
    for (int i = 0; i < 10; ++i) {
      e = e * 10;
      index[e % k][i]++;
    }
  }
  int64_t result = 0;
  for (uint64_t e : data) {
    uint64_t m = (k - (e % k)) % k;
    auto it = index.find(m);
    if (it != index.end()) {
      auto s = digits(e);
      result += (it->second)[s - 1];
      for (auto i = 0; i < s; ++i) {
        e = e * 10;
      }
      if (e % k == m) {
        result--;
      }
    }
  }
  std::cout << result << std::endl;
}
