#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
const int N = 2e5 + 10;
const int K = 20;
long long a[N], deg[N], ma[N], len[N];
int num[N], mas[N], ln = 0, lm = 0;
vector<vector<int>> d;
int main() {
  int n;
  long long k;
  scanf("%d %I64d", &n, &k);
  deg[0] = 1;
  for (int i = 1; i <= 18; i++) deg[i] = (deg[i - 1] * 10ll) % k;
  d.resize(11);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    int x = a[i];
    ma[i] = a[i] % k;
    while (x > 0) {
      len[i]++;
      x /= 10;
    }
    d[len[i]].push_back(ma[i]);
  }
  for (int i = 0; i <= 10; i++) sort(d[i].begin(), d[i].end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 10; j++) {
      int cur = k - (a[i] * deg[j] % k);
      int l = lower_bound(d[j].begin(), d[j].end(), cur) - d[j].begin();
      int r = upper_bound(d[j].begin(), d[j].end(), cur) - d[j].begin();
      ans += r - l;
      cur = 0 - (a[i] * deg[j] % k);
      l = lower_bound(d[j].begin(), d[j].end(), cur) - d[j].begin();
      r = upper_bound(d[j].begin(), d[j].end(), cur) - d[j].begin();
      ans += r - l;
    }
  }
  for (int i = 0; i < n; i++) {
    long long cur = ma[i] * deg[len[i]] % k + a[i];
    cur %= k;
    if (cur == 0) ans--;
  }
  cout << ans;
  return 0;
}
