#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  unordered_map<long long, long long> mp[11];
  for (long long i = 0; i < n; i++) {
    long long d = 0;
    long long temp = a[i];
    while (temp > 0) {
      temp /= 10;
      d++;
    }
    mp[d][a[i] % k]++;
  }
  long long res = 0;
  long long util[11];
  long long v = 1;
  for (long long j = 0; j <= 10; j++) {
    util[j] = v;
    v = (v * 10) % k;
  }
  for (long long i = 0; i < n; i++) {
    long long temp = a[i] % k;
    for (long long j = 1; j <= 10; j++) {
      temp = (temp * 10) % k;
      if (mp[j].find((k - temp) % k) != mp[j].end()) {
        res += mp[j][(k - temp) % k];
      }
    }
    long long d = 0;
    temp = a[i];
    while (temp > 0) {
      temp /= 10;
      d++;
    }
    temp = ((a[i] % k) * util[d]) % k;
    if (temp == ((k - (a[i] % k)) % k)) res--;
  }
  cout << res;
  return 0;
}
