#include <bits/stdc++.h>
using namespace std;
int digit(int x) {
  int c = 0;
  do {
    x /= 10;
    c++;
  } while (x != 0);
  return c;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
  long long ans = 0;
  for (int it = 0; it < 2; ++it) {
    map<pair<int, int>, int> mp;
    for (int i = 0; i < n; ++i) {
      int mf = v[i] % k;
      for (int j = 1; j <= 10; ++j) {
        mf = mf * 10ll % k;
        int com = (k - mf) % k;
        if (mp.find({com, j}) != mp.end()) ans += mp[{com, j}];
      }
      int com = v[i] % k;
      int lng = digit(v[i]);
      mp[{com, lng}]++;
    }
    reverse(v.begin(), v.end());
  }
  printf("%lld\n", ans);
  return 0;
}
