#include <bits/stdc++.h>
using namespace std;
int intlen(long long a) {
  int ans = 0;
  while (a > 0) {
    a /= 10;
    ans++;
  }
  return ans;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<long long> a(n, 0);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  vector<vector<long long> > rem(32, vector<long long>(n, 0));
  for (int i = 0; i < n; i++) rem[0][i] = a[i] % k;
  for (int i = 1; i < 32; i++)
    for (int j = 0; j < n; j++) rem[i][j] = (rem[i - 1][j] * 10) % k;
  for (int i = 0; i < 32; i++) sort((rem[i]).begin(), (rem[i]).end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int len = intlen(a[i]);
    int r = (k - (a[i] % k)) % k;
    int u =
        upper_bound((rem[len]).begin(), (rem[len]).end(), r) - rem[len].begin();
    int l =
        lower_bound((rem[len]).begin(), (rem[len]).end(), r) - rem[len].begin();
    ans += u - l;
    long long r2 = a[i] % k;
    for (int j = 0; j < len; j++) r2 = (r2 * (10 % k)) % k;
    if (r == r2) ans--;
  }
  printf("%lld\n", ans);
  return 0;
}
