#include <bits/stdc++.h>
using namespace std;
int n, k, le[200005], y[200005];
char x[20];
map<int, int> v[20];
long long cur, ans;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", x);
    le[i] = strlen(x);
    sscanf(x, "%d", y + i);
    v[le[i]][y[i] % k]++;
  }
  for (int i = 0; i < n; i++) {
    cur = y[i] % k;
    for (int j = 1; j < 20; j++) {
      cur = cur * 10 % k;
      auto it = v[j].find((k - cur) % k);
      if (it != v[j].end()) {
        ans += it->second;
        if (j == le[i] && (cur + y[i]) % k == 0) ans--;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
