#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const long long LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const long long MOD = 1000000007;
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const double PI = 3.141592653589793;
inline void fasterios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long ans, sep[15];
vector<long long> nums[15];
long long n, k, a[200005], d[200005];
int main() {
  cin >> n >> k;
  sep[0] = 1 % k;
  for (int i = 1; i <= 12; i++) sep[i] = (sep[i - 1] * 10) % k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    long long tmp = a[i];
    while (tmp != 0) {
      d[i]++;
      tmp /= 10;
    }
    a[i] %= k;
    nums[d[i]].push_back(a[i]);
  }
  for (int i = 1; i <= 10; i++) {
    sort(nums[i].begin(), nums[i].end());
  }
  for (int j = 1; j <= n; j++) {
    for (int i = 1; i <= 10; i++) {
      if (nums[i].size() == 0) continue;
      long long tmp = (a[j] * sep[i]) % k;
      long long fin = (k - tmp) % k;
      long long lb =
          lower_bound(nums[i].begin(), nums[i].end(), fin) - nums[i].begin();
      long long ub =
          upper_bound(nums[i].begin(), nums[i].end(), fin) - nums[i].begin();
      ans += (ub - lb);
    }
  }
  for (int i = 1; i <= n; i++)
    if ((((a[i] * sep[d[i]]) % k) + a[i]) % k == 0) ans--;
  cout << ans << '\n';
  return 0;
}
