#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e9;
const long long mod = 1e9 + 7;
const long double EPS = (1e-18);
int dcmp(long double x, long double y) {
  return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long double PI = 3.1415926535897932384626433832795028841971693993751;
const long long MAX = 3 * 100 * 1000 + 5;
long long n, k;
long long b[MAX];
map<long long, long long> a[11];
int dig(long long w) {
  int cnt = 0;
  while (w) {
    cnt++;
    w /= 10;
  }
  return cnt;
}
long long momo(long long w) { return w % k; }
int main() {
  fast();
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    a[dig(b[i])][momo(b[i])]++;
  }
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    long long po = 10;
    int to = 1;
    while (to <= 10) {
      long long mo = momo((b[i] % k) * (po % k));
      if (a[to].find({(k - mo) % k}) != a[to].end()) cnt += a[to][(k - mo) % k];
      if (dig(b[i]) == to && momo(b[i]) == ((k - mo) % k)) cnt--;
      po *= 10ll;
      to++;
    }
    bool f = 0;
    f = 1;
  }
  cout << cnt << endl;
  return 0;
}
