#include <bits/stdc++.h>
using namespace std;
long long pow1(long long n) {
  long long a = 1;
  for (long long i = 0; i < n; i++) {
    a *= 10;
  }
  return a;
}
int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> mp[11];
  long long a[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long j = 1; j <= 10; j++) {
    for (long long i = 0; i < n; i++) {
      long long p = a[i];
      long long count = 0;
      while (p != 0) {
        p /= 10;
        ++count;
      }
      long long rem = ((a[i] % m) * (pow1(j) % m)) % m;
      rem %= m;
      if (count == j && (m - rem) % m == a[i] % m) ans--;
      mp[j][(m - rem) % m]++;
    }
  }
  for (long long i = 0; i < n; i++) {
    long long rem = a[i] % m;
    long long count = 0;
    long long p = a[i];
    while (p != 0) {
      p /= 10;
      ++count;
    }
    ans += (mp[count][rem]);
  }
  cout << ans;
  return 0;
}
