#include <bits/stdc++.h>
using namespace std;
int digits(int x) {
  int r = 0;
  while (x > 0) {
    x /= 10;
    ++r;
  }
  return r;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int& ai : a) cin >> ai;
  vector<map<int, int>> f;
  vector<int> m;
  long long t = 10;
  for (int j = 0; j < 10; ++j) {
    map<int, int> c;
    for (int ai : a) ++c[(ai * t) % k];
    f.emplace_back(c);
    m.push_back(t);
    t = (10 * t) % k;
  }
  long long r = 0;
  for (int ai : a) {
    int d = digits(ai) - 1;
    r += f[d][(k - (ai % k)) % k];
    if ((long long)(m[d] + 1) * ai % k == 0) --r;
  }
  cout << r << endl;
  return 0;
}
