#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long n, k;
long long a[N], b[N], len[N], q[12];
vector<long long> vec[12];
int main() {
  scanf("%I64d%I64d", &n, &k);
  q[0] = 1;
  for (int i = 1; i <= 10; i++) q[i] = q[i - 1] * 10 % k;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) b[i] = a[i];
  for (int i = 1; i <= n; i++) {
    long long x = a[i];
    int cnt = 0;
    while (x) {
      x /= 10;
      cnt++;
    }
    len[i] = cnt;
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= n; j++) vec[i].push_back(a[j] * q[i] % k);
    sort(vec[i].begin(), vec[i].end());
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    b[i] %= k;
    int l = len[i];
    int pos1 = lower_bound(vec[l].begin(), vec[l].end(), (k - b[i]) % k) -
               vec[l].begin();
    int pos2 = upper_bound(vec[l].begin(), vec[l].end(), (k - b[i]) % k) -
               vec[l].begin();
    ans += (pos2 - pos1);
    if (a[i] * q[l] % k == (k - b[i]) % k && pos2 - pos1 > 0) ans--;
  }
  printf("%I64d", ans);
  return 0;
}
