#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << " = " << a << " ";
    call(++it, ed, rest...);
  }
};
int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};
const double PI = 2.0 * acos(0.0);
const double GOLD = (1.0 + sqrt(5.0)) / 2.0;
const double eps = 1e-9;
vector<int> p[15];
long long int ar[200010];
int len[200010];
int main() {
  int n;
  long long int k;
  cin >> n >> k;
  for (int i = (0); i < (n); i += (1)) {
    cin >> ar[i];
    long long int x = ar[i];
    int c = 0;
    while (x > 0) {
      ++c;
      x /= 10;
    }
    p[c].push_back(ar[i] % k);
    len[i] = c;
  }
  for (int i = (0); i < (12); i += (1)) {
    sort(p[i].begin(), p[i].end());
  }
  long long int ans = 0;
  for (int e = (0); e < (n); e += (1)) {
    long long int y = ar[e];
    long long int t = y % k;
    for (int i = 1; i <= 10; i++) {
      y = (y % k) * (10 % k);
      y %= k;
      long long int u = (k - y) % k;
      vector<int>::iterator a, b;
      a = lower_bound(p[i].begin(), p[i].end(), u);
      b = upper_bound(p[i].begin(), p[i].end(), u);
      if (a == p[i].end()) continue;
      long long int d = b - a;
      ans += d;
      if (len[e] == i && u == t) ans--;
    }
  }
  cout << ans;
}
