#include <bits/stdc++.h>
using namespace std;
long long k;
long long pw[21];
map<pair<long long, long long>, long long> m;
long long work(long long n) {
  long long u = n;
  long long d = 0;
  while (u) {
    d++;
    u /= 10;
  }
  m[make_pair(d, n % k)]++;
  return d;
}
long long calc(long long n, long long d) {
  long long ans = 0;
  for (long long i = d + 1; i < 21; i++) {
    long long j = i - d;
    if (j == d) {
      long long r1 = ((n % k) * pw[j]) % k;
      if (r1 == 0) {
        if (n % k == 0) {
          if (m.find(make_pair(j, r1)) != m.end())
            ans += max((long long)0, m[make_pair(j, r1)] - 1);
        } else {
          if (m.find(make_pair(j, r1)) != m.end())
            ans += max((long long)0, m[make_pair(j, r1)]);
        }
      } else {
        if (k - r1 == n % k) {
          if (m.find(make_pair(j, k - r1)) != m.end())
            ans += max((long long)0, m[make_pair(j, k - r1)] - 1);
        } else {
          if (m.find(make_pair(j, k - r1)) != m.end())
            ans += max((long long)0, m[make_pair(j, k - r1)]);
        }
      }
    } else {
      long long r1 = (n % k * pw[j]) % k;
      if (r1 == 0) {
        if (m.find(make_pair(j, r1)) != m.end())
          ans += max(m[make_pair(j, r1)], (long long)0);
      } else {
        if (m.find(make_pair(j, k - r1)) != m.end())
          ans += max((long long)0, m[make_pair(j, k - r1)]);
      }
    }
  }
  return ans;
}
long long check(long long n) {
  long long d = 0;
  long long u = n;
  while (u) {
    d++;
    u /= 10;
  }
  long long r1 = (n % k * pw[d]) % k;
  if (r1 == 0 && n % k == 0) return 1;
  if (k - r1 == n % k) return 1;
  return 0;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n >> k;
  ;
  pw[0] = 1;
  for (long long i = 1; i < 21; i++) pw[i] = (pw[i - 1] * 10) % k;
  vector<long long> v(n);
  vector<long long> d(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    d[i] = work(v[i]);
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += calc(v[i], d[i]);
  }
  cout << ans;
  return 0;
}
