#include <bits/stdc++.h>
using namespace std;
const int MAXN = 312345;
const int MAXINT = 2147483098;
const long long MAXLL = 9223372036854775258LL;
vector<long long> have[MAXN];
long long step[MAXN], a[MAXN];
int len(long long x) {
  int sz = 0;
  do {
    ++sz;
    x /= 10;
  } while (x);
  return sz;
}
long long count_of_number(long long x, vector<long long> &v) {
  long long l = (lower_bound(v.begin(), v.end(), x) - v.begin());
  long long r = (upper_bound(v.begin(), v.end(), x) - v.begin());
  return max(0LL, r - l);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k, ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    have[len(a[i])].push_back(a[i] % k);
  }
  step[0] = 1LL;
  for (int i = 1; i <= 20; ++i) {
    step[i] = (step[i - 1] * 10) % k;
    sort(have[i].begin(), have[i].end());
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 20; ++j) {
      long long need = ((a[i] % k) * (step[j] % k)) % k;
      need = (k - need) % k;
      ans += count_of_number(need, have[j]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    long long ost = ((a[i] % k) * (step[len(a[i])] % k)) % k;
    ost = (ost + a[i]) % k;
    if (ost == 0) --ans;
  }
  cout << ans << '\n';
  return 0;
}
