#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long a[200005], p[20], lg[200005];
struct hash_map {
  int head[200005], Next[200005], cnt;
  long long val[200005], tot[200005];
  hash_map() {
    cnt = 0;
    memset(head, 0, sizeof(head));
    memset(Next, 0, sizeof(Next));
    memset(val, 0, sizeof(val));
    memset(tot, 0, sizeof(tot));
  }
  void insert(long long x) {
    long long k = x % 10007;
    for (int i = head[k]; i; i = Next[i]) {
      if (val[i] == x) {
        tot[i]++;
        return;
      }
    }
    cnt++;
    Next[cnt] = head[k];
    head[k] = cnt;
    val[cnt] = x;
    tot[cnt] = 1;
  }
  long long find(long long x) {
    long long k = x % 10007;
    for (int i = head[k]; i; i = Next[i]) {
      if (val[i] == x) {
        return tot[i];
      }
    }
    return 0;
  }
} mp[15];
int main() {
  cin >> n >> k;
  p[0] = 1;
  for (int i = 1; i <= 10; i++) {
    p[i] = p[i - 1] * 10 % k;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    long long tmp = a[i];
    while (tmp) {
      lg[i]++;
      tmp /= 10;
    }
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= n; j++) {
      mp[i].insert(a[j] % k * p[i] % k);
    }
  }
  long long t, ans = 0;
  for (int i = 1; i <= n; i++) {
    t = ((k - a[i]) % k + k) % k;
    ans += mp[lg[i]].find(t);
    if ((a[i] % k * p[lg[i]] % k + a[i] % k) % k == 0) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
