#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int ndigs(int n) {
  int d = 0;
  while (n) {
    d++;
    n /= 10;
  }
  return d;
}
int main() {
  std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  map<int, int> has[11];
  long long pows[11];
  pows[0] = 1;
  for (int i = 1; i <= 10; i++) pows[i] = (pows[i - 1] * 10) % k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    has[ndigs(a[i])][a[i] % k]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int digs = ndigs(a[i]);
    int md = a[i] % k;
    has[digs][md]--;
    for (int j = 1; j <= 10; j++) {
      long long num = 1;
      num = num * (long long)pows[j] * (long long)a[i];
      long long md2 = num % k;
      if (has[j].find((k - md2) % k) != has[j].end())
        ans += (has[j][(k - md2) % k]) * 1LL;
    }
    has[digs][md]++;
  }
  cout << ans << "\n";
  return 0;
}
