#include <bits/stdc++.h>
using namespace std;
long long a[20][200010], n, k, v[200010], l[20], rez;
long long cauta1(long long x, long long lin) {
  long long st = 1, dr = l[lin], mij = (st + dr) / 2;
  while (st <= dr) {
    if (a[lin][mij] < x)
      st = mij + 1;
    else
      dr = mij - 1;
    mij = (st + dr) / 2;
  }
  return st;
}
long long cauta2(long long x, long long lin) {
  long long st = 1, dr = l[lin], mij = (st + dr) / 2;
  while (st <= dr) {
    if (a[lin][mij] <= x)
      st = mij + 1;
    else
      dr = mij - 1;
    mij = (st + dr) / 2;
  }
  return dr;
}
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    long long b = v[i], nr = 0;
    while (b) b /= 10, nr++;
    l[nr]++;
    a[nr][l[nr]] = v[i] % k;
  }
  for (long long i = 1; i <= 10; i++) sort(a[i] + 1, a[i] + l[i] + 1);
  for (long long i = 1; i <= n; i++) {
    long long b = v[i];
    for (long long j = 1; j <= 10; j++) {
      b = b * 10 % k;
      long long y = b % k;
      long long h = k - y;
      if (h == k) h = 0;
      long long st = cauta1(h, j);
      long long dr = cauta2(h, j);
      rez = rez + dr - st + 1;
    }
  }
  for (long long i = 1; i <= n; i++) {
    long long b = v[i], c = v[i], d = 1;
    while (c) b = b * 10 % k, c /= 10;
    b = b + v[i];
    if (b % k == 0) rez--;
  }
  cout << rez;
  return 0;
}
