#include <bits/stdc++.h>
using namespace std;
unordered_map<signed, signed> cnt[20];
long long Mod;
long long n;
long long a[200001];
long long L10[200001];
inline long long Log10(long long x) {
  long long res = 0;
  if (x == 0) return 1;
  while (x) res++, x /= 10;
  return res;
}
inline void insert(long long x) {
  for (long long i = 1; i <= 10; i++) {
    x *= 10;
    x %= Mod;
    cnt[i][x]++;
  }
}
inline long long calc(long long x, long long P) {
  long long k = Mod - x % Mod;
  if (k == Mod) k = 0;
  if (cnt[P].count(k) == 0) return 0;
  return cnt[P][k];
}
inline bool check(long long x, long long P) {
  long long Y = x;
  while (P--) Y = Y * 10 % Mod;
  Y += x;
  Y %= Mod;
  if (Y % Mod == 0) return 0;
  return 1;
}
signed main() {
  scanf("%lld%lld", &n, &Mod);
  long long ans = 0;
  for (long long i = 1; i <= n; i++)
    scanf("%lld", a + i), insert(a[i]), L10[i] = Log10(a[i]);
  for (long long i = 1; i <= n; i++) {
    ans += calc(a[i], L10[i]);
    if (check(a[i], L10[i]) == 0) ans--;
  }
  printf("%lld", ans);
  return 0;
}
