#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int f(int x) {
  int k = log10(x);
  return k;
}
vector<int> cnt[11];
int arr[200009], pw[11], n, k;
int solve(int x, int y) { return ((x * 1LL * pw[y + 1] + x) % k == 0); }
int main() {
  scanf("%d%d", &n, &k);
  pw[0] = 1;
  for (int i = 1; i <= 10; i++) pw[i] = (pw[i - 1] * 10LL) % k;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    ans -= solve(x % k, f(x));
    cnt[f(x)].push_back(x % k);
    arr[i] = x;
  }
  for (int i = 0; i < 10; i++) sort(cnt[i].begin(), cnt[i].end());
  int val, p1, p2;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 10; j++) {
      val = (k - (((arr[i] % k) * 1LL * pw[j + 1]) % k)) % k;
      p1 = lower_bound(cnt[j].begin(), cnt[j].end(), val) - cnt[j].begin();
      p2 = upper_bound(cnt[j].begin(), cnt[j].end(), val) - cnt[j].begin();
      ans += p2 - p1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
