#include <bits/stdc++.h>
using namespace std;
vector<int> mp[12];
int main() {
  int n;
  unsigned long long int k;
  cin >> n >> k;
  unsigned long long int a[n];
  for (auto &x : a) cin >> x;
  for (auto x : a) {
    int len;
    if (x != 0)
      len = log10(x);
    else
      len = 0;
    len++;
    unsigned long long int mod = x % k;
    mp[len].push_back(mod);
  }
  for (int i = 0; i < 11; i++) {
    sort(mp[i].begin(), mp[i].end());
  }
  unsigned long long int ans = 0;
  for (auto x : a) {
    int len;
    if (x != 0)
      len = log10(x);
    else
      len = 0;
    unsigned long long int sm = 1;
    len++;
    unsigned long long int mod = x % k;
    for (int i = 1; i <= 10; i++) {
      sm *= 10;
      unsigned long long int fx = x * sm;
      unsigned long long int need = (fx + k - 1) / k;
      need *= k;
      need -= fx;
      if (need == mod && i == len) {
        ans--;
      }
      need %= k;
      ans += (unsigned long long int)(upper_bound(mp[i].begin(), mp[i].end(),
                                                  need) -
                                      lower_bound(mp[i].begin(), mp[i].end(),
                                                  need));
    }
  }
  cout << ans << endl;
  return 0;
}
