#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int sz = 10;
map<int, int> mp[11];
int n, k;
unsigned long long a[maxn], ans;
unsigned long long fac[13];
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 10; i++) fac[i] = 10LL * fac[i - 1];
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%llu", &a[i]);
    for (int j = 1; j <= 10; j++) {
      int now = (a[i] * fac[j]) % k;
      mp[j][now]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int len = 0;
    unsigned long long now = a[i];
    while (now) {
      now /= 10;
      len++;
    }
    int res = a[i] % k;
    int p = 0;
    if (res == 0) {
      int need = 0;
      if ((a[i] * fac[len]) % k == need) {
        ans += mp[len][need] - 1;
      } else {
        ans += mp[len][need];
      }
    } else {
      int need = k - res;
      if ((a[i] * fac[len]) % k == need) {
        ans += mp[len][need] - 1;
      } else {
        ans += mp[len][need];
      }
    }
  }
  printf("%lld\n", ans);
}
