#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long MOD = 1000000007LL;
const int M = 5000005;
const int N = 500005;
int n, c[N];
long long ans, a[N], b[15], d[N], t, m;
map<long long, int> mp[15];
int main() {
  scanf("%d %lld", &n, &m);
  b[0] = 1LL;
  for (int i = 1; i <= 10; i++) b[i] = b[i - 1] * 10LL;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    for (int j = 1; j <= 10; j++)
      if (a[i] < b[j]) {
        c[i] = j;
        break;
      }
    d[i] = a[i] % m;
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= n; j++) {
      t = b[i] % m * d[j];
      t %= m;
      if (!mp[i].count(t))
        mp[i][t] = 1;
      else
        mp[i][t]++;
    }
  }
  ans = 0LL;
  for (int i = 1; i <= n; i++) {
    t = (m - d[i]) % m;
    if (mp[c[i]].count(t)) {
      ans += (long long)mp[c[i]][t];
      if (t == (b[c[i]] % m * d[i]) % m) ans--;
    }
  }
  printf("%lld\n", max(ans, 0LL));
  return 0;
}
