#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp[15];
long long k, a[200010];
int n, l[200010], r[200010];
long long ans = 0;
int itos(long long x) {
  int now = 0;
  while (x) {
    now++;
    x /= 10;
  }
  return now;
}
void add(int p) {
  long long now = a[p];
  for (int i = 1; i <= 10; i++) {
    now *= 10;
    now %= k;
    mp[i][now]++;
    if (i == l[p]) r[p] = now;
  }
}
void sub(long long x) {
  long long now = x;
  for (int i = 1; i <= 10; i++) {
    now *= 10;
    now %= k;
    mp[i][now]--;
  }
}
int cal(int p) {
  int anss = 0;
  if (a[p] % k == 0)
    anss = mp[l[p]][0] - (r[p] == 0);
  else
    anss = mp[l[p]][k - (a[p] % k)] - (r[p] == k - (a[p] % k));
  return anss;
}
int main() {
  cin.tie(0), cout.sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    l[i] = itos(a[i]);
    add(i);
  }
  for (int i = 0; i < n; i++) ans += cal(i);
  cout << ans << '\n';
  return 0;
}
