#include <bits/stdc++.h>
using namespace std;
int cal(int a) {
  int i = 0;
  while (a > 0) {
    a /= 10;
    i++;
  }
  return i;
}
vector<int> plac[10];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[n], b[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    b[i] = cal(a[i]);
    plac[b[i]].push_back(a[i] % k);
  }
  long long di[11] = {1};
  for (int i = 1; i < 11; i++) {
    di[i] = di[i - 1] * 10 % k;
    sort(plac[i].begin(), plac[i].end());
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      int l = (a[i] * di[j]) % k;
      int p = (k - l) % k;
      auto low = lower_bound(plac[j].begin(), plac[j].end(), p);
      auto up = upper_bound(plac[j].begin(), plac[j].end(), p);
      ans += (int)(up - low);
      if (b[i] == j && (a[i] + l) % k == 0) ans--;
    }
  }
  cout << ans;
}
