#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const double pi = acos(-1);
int n, i, j, k, t;
int a[200005], b[200004];
int hit[200005][11];
map<int, int> le[11];
int cdigit(int val) {
  int tmp = 0;
  while (val) {
    ++tmp;
    val /= 10;
  }
  return tmp;
}
int main() {
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; ++i) {
    scanf("%d", a + i);
    b[i] = cdigit(a[i]);
    hit[i][0] = a[i] % k;
    for (j = 1; j <= 10; ++j) {
      hit[i][j] = 10LL * hit[i][j - 1] % k;
      ++le[j][hit[i][j]];
    }
  }
  long long ans = 0;
  for (i = 0; i < n; ++i) {
    int tmp = (k - hit[i][0]) % k;
    int cnt = 0;
    if (le[b[i]].count(tmp)) {
      cnt += le[b[i]][tmp];
      if (hit[i][b[i]] == tmp) --cnt;
    }
    ans += cnt;
  }
  printf("%lld\n", ans);
  return 0;
}
