#include <bits/stdc++.h>
using namespace std;
const int MAXN = 212345;
const int MAXD = 11;
int k, A[MAXN];
long long int modval[MAXD][MAXN];
map<int, int> cnt[MAXD];
inline int dig(int x) {
  if (x == 0) return 1;
  int cur = 0;
  while (x > 0) {
    x /= 10;
    cur++;
  }
  return cur;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  long long int ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < n; i++) {
    modval[0][i] = A[i] % k;
    for (int j = 1; j < MAXD; j++) {
      modval[j][i] = (modval[j - 1][i] * 10) % k;
      if (cnt[j].count(modval[j][i]))
        cnt[j][modval[j][i]]++;
      else
        cnt[j][modval[j][i]] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    int d = dig(A[i]);
    int negmod = (k - (A[i] % k)) % k;
    if (cnt[d].count(negmod)) ans += cnt[d][negmod] - (modval[d][i] == negmod);
  }
  cout << ans << '\n';
  return 0;
}
