#include <bits/stdc++.h>
const int M = 12;
const int N = 200100;
using namespace std;
int a[N];
long long pow_10[M];
map<int, int> cnt[M];
inline int get_len(int x) {
  int len = 0;
  while (x != 0) {
    len++;
    x /= 10;
  }
  return len;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  pow_10[0] = 1 % k;
  for (int i = 1; i < M; i++) pow_10[i] = (pow_10[i - 1] * 10) % k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i] = x;
    cnt[get_len(x)][x % k]++;
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    for (int len = 1; len <= 10; len++) {
      int rem_x = (1ll * (a[i] % k) * pow_10[len]) % k;
      int req_rem_y = (k - rem_x) % k;
      auto it = cnt[len].find(req_rem_y);
      if (it == cnt[len].end()) continue;
      res += it->second;
      if (req_rem_y == (a[i] % k) && get_len(a[i]) == len) res--;
    }
  }
  cout << res << '\n';
  return 0;
}
