#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, k;
long long ans;
int a[maxn], wei[maxn], b[maxn][11];
map<int, int> mp[11];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    wei[i] = log10(a[i]) + 1;
    a[i] %= k;
    int x = a[i];
    mp[0][x]++;
    b[i][0] = x;
    for (int j = 1; j <= 10; j++) {
      x = 1ll * x * 10 % k;
      b[i][j] = x;
      mp[j][x]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int rev = (k - a[i] == k) ? 0 : k - a[i];
    if (mp[wei[i]].count(rev)) ans += mp[wei[i]][rev];
    if (b[i][wei[i]] == rev) ans--;
  }
  printf("%lld", ans);
  return 0;
}
