#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int maxn = 3e5 + 10;
const long long mod = 1e9 + 7;
const int maxm = 1e6 + 10;
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
const double INF = 1e20;
const double pi = acos(-1.0);
int n;
int k;
int a[maxn];
int cal(long long x) {
  long long num = 0;
  while (x) {
    num++;
    x /= 10;
  }
  return num;
}
int len[maxn];
map<pair<int, int>, int> ma;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    len[i] = cal(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (ma.find(make_pair(len[i], a[i] % k)) != ma.end())
      ma[make_pair(len[i], a[i] % k)]++;
    else
      ma.insert(make_pair(make_pair(len[i], a[i] % k), 1));
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ma[make_pair(len[i], a[i] % k)]--;
    int temp = a[i];
    for (int j = 1; j <= 10; j++) {
      int num1 = (1LL * temp * 10) % k;
      temp = num1;
      int num2 = (num1 == 0 ? 0 : k - num1);
      if (ma.find(make_pair(j, num2)) == ma.end()) continue;
      ans += ma[make_pair(j, num2)];
    }
    ma[make_pair(len[i], a[i] % k)]++;
  }
  printf("%lld\n", ans);
  return 0;
}
