#include <bits/stdc++.h>
using namespace std;
long long int powermodm(long long int x, long long int n, long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long int power(long long int _a, long long int _b) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long int gcd(long long int a, long long int b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
long long int lcm(long long int a, long long int b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
int n, k, a[200005], len[200005], pw[11];
unordered_map<int, int> mp[11];
void fun() {
  long long int tempans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = a[i];
    for (int j = 1; j < 11; j++) {
      tmp = ((long long int)tmp * 10) % k;
      mp[j][tmp]++;
    }
  }
  for (int i = 0; i < n; i++) {
    int tmp = a[i], y = tmp;
    long long int p = (tmp * pw[len[i]]) % k;
    mp[len[i]][p]--;
    tempans += mp[len[i]][(k - tmp) % k];
    mp[len[i]][p]++;
  }
  printf("%lld", tempans);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int val;
  cin >> n >> k;
  int tmp = 1;
  for (int i = 1; i < 11; i++) {
    tmp = ((long long int)tmp * 10) % k;
    pw[i] = tmp;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    val = a[i];
    while (val) {
      len[i]++;
      val /= 10;
    }
    a[i] %= k;
  }
  fun();
  return 0;
}
