#include <bits/stdc++.h>
using namespace std;
struct node {
  struct ar {
    int v;
  };
  ar a[12];
  int ln, mv;
};
node A[200005];
map<pair<int, int>, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, k, i, j, y, l, p, q, b;
  long long x;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &b);
    x = b;
    x %= k;
    for (j = 1; j <= 10; j++) {
      A[i].a[j].v = (x * 10) % k;
      x = (x * 10) % k;
    }
    x = b;
    l = 0;
    while (x) {
      x /= 10;
      l++;
    }
    mp[{l, b % k}]++;
    A[i].ln = l;
    A[i].mv = b % k;
  }
  long long z = 0;
  for (i = 0; i < n; i++) {
    for (j = 1; j <= 10; j++) {
      x = A[i].a[j].v;
      y = k - x;
      if (x == 0) {
        z += mp[{j, x}];
        if (A[i].ln == j && x == A[i].mv) {
          z--;
        }
      }
      z += mp[{j, y}];
      if (A[i].ln == j && y == A[i].mv) {
        z--;
      }
    }
  }
  printf("%lld\n", z);
  return 0;
}
