#include <bits/stdc++.h>
using namespace std;
map<pair<int, long long>, long long> cnt;
int bitcount(long long x) { return (int)log10(x) + 1; }
int n, x[200010];
long long k, a[200010], ans;
int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    x[i] = bitcount(a[i]);
    cnt[make_pair(x[i], a[i] % k)]++;
  }
  for (int i = 1; i <= n; i++) {
    long long tmp = a[i], t;
    for (int j = 1; j <= 10; j++) {
      tmp = tmp * 10 % k;
      t = tmp ? k - tmp : 0;
      if (cnt.count(make_pair(j, t))) {
        ans += cnt[make_pair(j, t)];
      }
    }
    tmp = a[i];
    for (int j = 1; j <= x[i]; j++) {
      tmp = tmp * 10 % k;
    }
    if ((tmp + a[i]) % k == 0) {
      ans--;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
