#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, k, a[N], rr[N], len[N];
map<int, int> mp[11];
int get(long long x) {
  int res = 0;
  while (x) {
    res++;
    x /= 10;
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  long long cur;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    rr[i] = a[i] % k;
    len[i] = get(a[i]);
    mp[len[i]][rr[i]]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    mp[len[i]][rr[i]]--;
    cur = (1ll * a[i] * 10) % k;
    for (int j = 1; j < 11; j++) {
      if (cur == 0)
        ans += mp[j][cur];
      else
        ans += mp[j][k - cur];
      cur = (cur * 10) % k;
    }
    mp[len[i]][rr[i]]++;
  }
  printf("%lld\n", ans);
  return 0;
}
