#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp[15];
long long b[15];
long long c[200005];
long long a[200005];
long long d[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  b[0] = 1LL;
  for (int i = 1; i <= 10; i++) {
    b[i] = b[i - 1] * 10LL;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 1; j <= 10; j++) {
      if (a[i] < b[j]) {
        c[i] = j;
        break;
      }
    }
    d[i] = a[i] % m;
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= n; j++) {
      long long t = b[i] % m * d[j];
      t %= m;
      if (!mp[i].count(t))
        mp[i][t] = 1;
      else
        mp[i][t]++;
    }
  }
  long long ans = 0LL;
  for (int i = 1; i <= n; i++) {
    long long t = (m - d[i]) % m;
    if (mp[c[i]].count(t)) {
      ans += (long long)mp[c[i]][t];
      if (t == (b[c[i]] % m * d[i]) % m) ans--;
    }
  }
  cout << max(ans, 0LL) << endl;
  return 0;
}
