#include <bits/stdc++.h>
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
using namespace std;
const int N = 2e5 + 5;
long long n, k;
long long x;
vector<long long> vec[11];
long long f[11];
long long ans;
map<long long, long long> mp;
long long num(long long x) {
  long long temp = 0;
  while (x) {
    x /= 10;
    temp++;
  }
  return temp;
}
int main() {
  long long have;
  scanf("%lld%lld", &n, &k);
  f[0] = 1ll;
  for (long long i = 1; i <= 10; i++) f[i] = f[i - 1] * 10 % k;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &x);
    vec[num(x)].push_back(x);
  }
  for (long long i = 1; i <= 10; i++) {
    mp.clear();
    for (auto temp : vec[i]) mp[temp % k]++;
    for (auto temp : vec[i]) {
      have = (k - temp * f[i] % k) % k;
      if (temp % k == have)
        ans += (mp[have] - 1);
      else
        ans += (mp[have]);
    }
    for (long long j = 1; j <= 10; j++) {
      if (i != j) {
        for (auto xx : vec[j]) {
          have = (k - xx * f[i] % k) % k;
          ans += (mp[have]);
        }
      }
    }
  }
  printf("%lld\n", ans);
}
