#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int getlen(int x) {
  int sum = 0;
  while (x) {
    ++sum;
    x /= 10;
  }
  return sum;
}
map<int, int> mp[25];
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    for (int i = 0; i < n; ++i) {
      scanf("%lld", &a[i]);
      int len = getlen(a[i]);
      mp[len][a[i] % k]++;
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      long long mul = 1;
      int len = getlen(a[i]);
      mp[len][a[i] % k]--;
      for (int j = 1; j <= 10; ++j) {
        mul *= 10;
        unsigned long long temp = a[i] * mul;
        if (mp[j].find((k - temp % k) % k) != mp[j].end())
          ans += mp[j][(k - temp % k) % k];
      }
      mp[len][a[i] % k]++;
    }
    printf("%lld\n", ans);
    for (int i = 0; i < 25; ++i) mp[i].clear();
  }
  return 0;
}
