#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
const int M = 1e9 + 7;
int coun(long long n) {
  int cnt = 0;
  while (n > 0) {
    cnt++;
    n /= 10;
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  map<long long, long long> mp[25];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mp[coun(v[i])][v[i] % k]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    mp[coun(v[i])][v[i] % k]--;
    for (long long j = 10, len = 1; len <= 10; j *= 10, len++) {
      long long mod = ((v[i] % k) * (j % k)) % k;
      if (mod == 0) mod = k;
      if (mp[len].count(k - mod)) {
        ans += mp[len][k - mod];
      }
    }
    mp[coun(v[i])][v[i] % k]++;
  }
  cout << ans;
  return 0;
}
