#include <bits/stdc++.h>
using namespace std;
long long int getLength(long long int x) {
  long long int c = 0;
  while (x > 0) {
    c++;
    x /= 10;
  }
  return c;
}
int main() {
  long long int n, k, i, j;
  cin >> n >> k;
  long long int a[n], lengths[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    lengths[i] = getLength(a[i]);
  }
  vector<vector<long long int>> v(11);
  long long int l, m;
  for (i = 0; i < n; i++) {
    l = lengths[i];
    m = a[i] % k;
    v[l].push_back(m);
  }
  for (i = 0; i <= 10; i++) {
    sort(v[i].begin(), v[i].end());
  }
  long long int ans = 0, avail, req;
  for (i = 0; i < n; i++) {
    for (j = 1; j <= 10; j++) {
      avail = (a[i] % k * ((long long int)(pow(10, j)) % k)) % k;
      req = (k - avail) % k;
      auto l = lower_bound(v[j].begin(), v[j].end(), req);
      auto r = upper_bound(v[j].begin(), v[j].end(), req);
      ans += (r - l);
      if (lengths[i] == j && (avail + a[i] % k) % k == 0) --ans;
    }
  }
  cout << ans << endl;
}
