#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 13;
const int LOGN = 11;
long n, k, l;
int a[N];
int len[N];
vector<int> rems[LOGN];
long long pw[LOGN];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  pw[0] = 1;
  for (int i = 0; i < LOGN - 1; i++) pw[i + 1] = pw[i] * 10 % k;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    while (x > 0) {
      ++len[i];
      x /= 10;
    }
    rems[len[i]].push_back(a[i] % k);
  }
  for (int i = 0; i < LOGN; i++) sort(rems[i].begin(), rems[i].end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < LOGN; ++j) {
      int rem = (a[i] * (pw[j])) % k;
      int xrem = (k - rem) % k;
      vector<int>::iterator l;
      l = lower_bound(rems[j].begin(), rems[j].end(), xrem);
      vector<int>::iterator r;
      r = upper_bound(rems[j].begin(), rems[j].end(), xrem);
      ans += (r - l);
      if (len[i] == j && (rem + a[i] % k) % k == 0) --ans;
    }
  }
  cout << ans;
  return 0;
}
