#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 7;
const long long mod = 1e9 + 7;
long long n, k, t, need, A[maxn], h[maxn];
unsigned long long cn, mult;
map<long long, long long> m[11];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) {
    cin >> A[i];
    t = A[i];
    while (t) t /= 10, h[i]++;
    m[h[i]][A[i] % k]++;
  }
  for (long long i = 0; i < n; ++i) {
    m[h[i]][A[i] % k]--;
    mult = 10;
    for (long long z = 1; z < 11; ++z) {
      need = (k - (mult * A[i]) % k);
      auto it = m[z].find((need == k ? 0 : need));
      if (it != m[z].end()) cn += it->second;
      mult *= 10;
    }
    m[h[i]][A[i] % k]++;
  }
  cout << cn << endl;
}
