#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void wr(T... args) {
  ((cout << args << " "), ...);
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto& i : a) cin >> i;
  int pow[11];
  pow[0] = 1;
  for (int i = 1; i <= 10; i++) pow[i] = (ll)pow[i - 1] * 10 % k;
  map<int, int> cnt[11];
  for (auto x : a) {
    cnt[(int)log10(x) + 1][x % k]++;
  }
  ll ans = 0;
  for (auto x : a) {
    cnt[(int)log10(x) + 1][x % k]--;
    for (int bit = 1; bit <= 10; bit++) {
      int xx = (ll)x * pow[bit] % k;
      ans += cnt[bit][(k - xx) % k];
    }
    cnt[(int)log10(x) + 1][x % k]++;
  }
  cout << ans;
  return 0;
}
