#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n + 1), mod(n + 1), length(n + 1);
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    mod[i] = v[i] % k;
  }
  long long l = 0;
  for (long long i = 1; i <= n; i++) {
    long long k = v[i];
    long long e = 0;
    while (k > 0) {
      e++;
      k /= 10;
    }
    l = max(l, e);
    length[i] = e;
  }
  vector<vector<long long>> x(l + 1), y(l + 1);
  for (long long i = 1; i <= n; i++) {
    y[length[i]].push_back(v[i] % k);
  }
  for (long long i = 1; i < y.size(); i++) {
    sort(y[i].begin(), y[i].end());
  }
  long long count = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= l; j++) {
      long long p = 1, ten = 10;
      for (long long z = 1; z <= j; z++) {
        p = (p % k * ten % k) % k;
      }
      long long m = ((v[i] % k) * (p % k)) % k;
      m = (k - m) % k;
      if (binary_search(y[j].begin(), y[j].end(), m)) {
        long long low = lower_bound(y[j].begin(), y[j].end(), m) - y[j].begin();
        long long high =
            upper_bound(y[j].begin(), y[j].end(), m) - y[j].begin();
        count += (high - low);
      }
      if (length[i] == j && mod[i] == m) {
        count--;
      }
    }
  }
  cout << count << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
