#include <bits/stdc++.h>
using namespace std;
char moji[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char moji2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char moji3[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
long long keta(long long x) {
  long long ans = 0;
  while (x > 0) {
    ans += 1;
    x /= 10;
  }
  return ans;
}
int main() {
  long long beki[11];
  beki[0] = 1;
  for (int i = 0; i < 10; i++) beki[i + 1] = 10 * beki[i];
  int n;
  cin >> n;
  long long k;
  cin >> k;
  long long A[int(2 * 1e5 + 5)];
  for (int i = 0; i < n; i++) scanf("%lld", &A[i]);
  map<long long, long long> mymap[11];
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < n; j++) {
      long long tmp = (beki[i] % k) * (A[j] % k);
      tmp %= k;
      if (mymap[i].find(tmp) == mymap[i].end())
        mymap[i][tmp] = 1;
      else
        mymap[i][tmp] += 1;
    }
  }
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    long long tmp = keta(A[i]);
    if (mymap[tmp].find((k - A[i] % k) % k) == mymap[tmp].end()) continue;
    ans += mymap[tmp][(k - A[i] % k) % k];
    if ((k - A[i] % k) % k == ((beki[tmp] % k) * (A[i] % k)) % k) ans -= 1;
  }
  cout << ans << endl;
}
