#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
const int oo = 1e9;
int MOD;
int mul(int a, int b) {
  long long ab = 1ll * a * b;
  if (ab >= MOD) return ab % MOD;
  return ab;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  while (cin >> n >> MOD) {
    vector<int> pot10(20);
    pot10[0] = 1;
    for (int i = 1; i < 11; i++) pot10[i] = mul(pot10[i - 1], 10);
    vector<int> a(n);
    vector<unordered_map<int, int>> cnt(11);
    for (auto &e : a) {
      cin >> e;
      int cur = e;
      for (int i = 1; i <= 10; i++) {
        cur = mul(cur, 10);
        cnt[i][cur]++;
      }
    }
    long long ans = 0;
    for (auto &e : a) {
      int pr = e;
      int cur = pr;
      int n_digit = 0;
      cur = e;
      while (cur) n_digit++, cur /= 10;
      int got = mul(pr, pot10[n_digit]);
      --cnt[n_digit][got];
      e %= MOD;
      e = MOD - e;
      if (e == MOD) e -= MOD;
      if (cnt[n_digit].count(e)) ans += cnt[n_digit][e];
      cur = pr;
      ++cnt[n_digit][got];
    }
    cout << ans << '\n';
  }
  return 0;
}
