#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int N = (int)1e6 + 7;
int n, k;
int a[N], bit[N];
map<int, int> cnt[11];
long long dp[N][11];
void Init() {
  for (int i = (1); i < (11); ++i) cnt[i].clear();
  for (int i = (0); i < (n); ++i) scanf("%d", a + i);
  for (int i = (0); i < (n); ++i) {
    int x = a[i];
    bit[i] = 0;
    while (x) {
      bit[i]++;
      x /= 10;
    }
  }
}
int Solve() {
  for (int i = (0); i < (n); ++i) {
    cnt[bit[i]][a[i] % k]++;
    dp[i][0] = a[i] % k;
    for (int j = (1); j < (11); ++j) dp[i][j] = dp[i][j - 1] * 10 % k;
  }
  long long ans = 0;
  for (int i = (0); i < (n); ++i) {
    for (int j = (1); j < (11); ++j) {
      if (bit[i] == j && (dp[i][j] + a[i]) % k == 0) --ans;
      int t = k - dp[i][j] != k ? k - dp[i][j] : 0;
      if (cnt[j].count(t)) ans += cnt[j][t];
    }
  }
  return !printf("%lld\n", ans);
}
int main() {
  while (~scanf("%d%d", &n, &k)) {
    Init();
    Solve();
  }
  return 0;
}
