#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
int xsize(int x) {
  int res = 0;
  while (x > 0) {
    x = x / 10;
    res++;
  }
  return res;
}
int correct_mod(long long x, int k) {
  int res = x % k;
  if (res < 0) res += k;
  return res;
}
int main() {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  map<pair<int, int>, int> map_a;
  for (int i = 0; i < n; i++) {
    int amod = a[i] % k;
    int asize = xsize(a[i]);
    map_a[make_pair(amod, asize)]++;
  }
  std::vector<int> tmp{10,      100,      1000,      10000,     100000,
                       1000000, 10000000, 100000000, 1000000000};
  tmp.emplace_back((long long)10000000000 % k);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      res += map_a[make_pair(correct_mod((long long)-a[i] * tmp[j], k), j + 1)];
    }
    if (((long long)a[i] + (long long)tmp[xsize(a[i]) - 1] * a[i]) % k == 0)
      res--;
  }
  cout << res;
  return 0;
}
