#include <bits/stdc++.h>
using namespace std;
long long a[250000];
int b[250000];
map<pair<int, int>, int> mp;
int ch(long long v) {
  int ans = 0;
  for (; v; ans++, v /= 10)
    ;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int n, k;
  long long ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i], b[i] = ch(a[i]);
    long long v = a[i] % k;
    for (int j = 0; j < 11; j++) {
      if (mp.find({j, (k - v + k) % k}) != mp.end())
        ans += mp[{j, (k - v + k) % k}];
      v = (v * 10) % k;
    }
    mp[{b[i], a[i] % k}]++;
  }
  mp.clear();
  for (int i = n - 1; i >= 0; i--) {
    long long v = a[i] % k;
    for (int j = 0; j < 11; j++) {
      if (mp.find({j, (k - v + k) % k}) != mp.end())
        ans += mp[{j, (k - v + k) % k}];
      v = (v * 10) % k;
    }
    mp[{b[i], a[i] % k}]++;
  }
  cout << ans;
  return 0;
}
