#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int M = 1LL << 30;
const int inf = 1e9 + 7;
const long long INF = 1e18;
const double eps = 1e-6;
const double PI(acos(-1.0));
int n, k;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  vector<long long> a(n), b(n);
  long long x;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    x = a[i];
    a[i] %= k;
    while (x) {
      b[i]++;
      x /= 10;
    }
  }
  long long s = 0;
  for (int tm = 0; tm < (2); tm++) {
    map<int, int> r[11];
    for (int i = 0; i < (n); i++) {
      long long t = a[i];
      for (int d = 1; d <= 10; d++) {
        t = t * 10 % k;
        int h = k - t;
        h %= k;
        if (r[d].find(h) != r[d].end()) {
          s += r[d][h];
        }
      }
      r[b[i]][a[i]]++;
    }
    reverse((a).begin(), (a).end());
    reverse((b).begin(), (b).end());
  }
  cout << s << endl;
}
