#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
const int N = 200005, K = 11;
int n, k;
int a[N], d[N];
vector<int> rem[K];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    d[i] = log10(a[i]) + 1;
    rem[d[i]].push_back(a[i] % k);
  }
  for (int i = 1; i < K; ++i) {
    sort(rem[i].begin(), rem[i].end());
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ull x = 10ll * a[i];
    for (int j = 1; j < K; ++j) {
      int nd = (k - (x % k)) % k;
      int l = lower_bound(rem[j].begin(), rem[j].end(), nd) - rem[j].begin();
      int r = upper_bound(rem[j].begin(), rem[j].end(), nd) - rem[j].begin();
      ans += r - l;
      x *= 10;
      if (d[i] == j && nd == a[i] % k) {
        --ans;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
