#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int oo = INT_MAX;
const int maxn = 200002;
int n, k, a[maxn], b[maxn];
vector<int> ve[11];
long long ans = 0;
int Get(int x) {
  int u = x, cnt = 0;
  while (u) {
    ++cnt;
    u = u / 10;
  }
  return cnt;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = Get(a[i]);
    a[i] = a[i] % k;
    ve[b[i]].push_back(a[i]);
  }
  for (int i = 0; i <= 10; i++) sort(ve[i].begin(), ve[i].end());
  for (int i = 1; i <= n; i++) {
    long long x = a[i];
    for (int j = 1; j <= 10; j++) {
      x = (x * 10) % k;
      vector<int>::iterator l, r;
      l = lower_bound(ve[j].begin(), ve[j].end(), (k - x) % k);
      r = upper_bound(ve[j].begin(), ve[j].end(), (k - x) % k);
      ans += r - l;
      if (b[i] == j && (x + a[i]) % k == 0) ans--;
    }
  }
  printf("%lld", ans);
  return 0;
}
