#include <bits/stdc++.h>
using namespace std;
void IO() {}
long long countDigit(long long n) {
  long long count = 0;
  while (n) {
    n /= 10;
    count++;
  }
  return count;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  map<long long, long long> m[11];
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    a[i] = t;
    m[countDigit(t)][t % k]++;
  }
  long long pCount[11];
  pCount[0] = 1;
  for (long long i = 1; i < 11; i++) {
    pCount[i] = pCount[i - 1] * 10;
    pCount[i] %= k;
  }
  long long count = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j < 11; j++) {
      long long target = (k - (a[i] * pCount[j]) % k) % k;
      count += m[j][target];
    }
  }
  for (long long i = 0; i < n; i++) {
    if (((a[i] * pCount[countDigit(a[i])]) % k + a[i]) % k == 0) {
      count--;
    }
  }
  cout << count << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  IO();
  solve();
  return 0;
}
