#include <bits/stdc++.h>
long long order_to_decimal[] = {10,         100,        1000,     10000,
                                100000,     1000000,    10000000, 100000000,
                                1000000000, 10000000000};
const int NUM_ORDERS = sizeof(order_to_decimal) / sizeof(long long);
inline int detect_order(int num, int order) {
  if (num == 0) return 0;
  if (order == 0 || (order == 1 && num != 0)) return order;
  int hiorder = order / 2;
  int loorder = order - hiorder;
  if (int hinum = num / order_to_decimal[loorder - 1])
    return detect_order(hinum, hiorder) + loorder;
  return detect_order(num, loorder);
}
inline int detect_order(int num) {
  if (num == 0) return 1;
  return detect_order(num, NUM_ORDERS);
}
int main() {
  unsigned long long answer = 0;
  int n = 0, k = 0;
  std::cin >> n >> k;
  unsigned long long* values = new unsigned long long[n];
  unsigned* orders = new unsigned[n];
  std::vector<std::map<int, int> > smth(NUM_ORDERS);
  unsigned min_order = NUM_ORDERS;
  unsigned max_order = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    std::cin >> a;
    values[i] = a % k;
    orders[i] = detect_order(a) - 1;
    min_order = std::min(min_order, orders[i]);
    max_order = std::max(max_order, orders[i]);
  }
  for (int j = min_order; j <= max_order; j++) {
    for (int i = 0; i < n; i++) {
      auto ttt = (values[i] * order_to_decimal[j]) % k;
      auto it = smth[j].find(ttt);
      if (it != smth[j].end())
        it->second++;
      else
        smth[j][ttt] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    auto val = values[i];
    auto rest = val ? k - val : 0;
    auto it = smth[orders[i]].find(rest);
    if (it != smth[orders[i]].end()) answer += it->second;
    if ((val * order_to_decimal[orders[i]] + val) % k == 0) answer--;
  }
  std::cout << answer << std::endl;
  return 0;
}
