#include <bits/stdc++.h>
using namespace std;
pair<long long int, long long int> a[2 * 100000];
unsigned long long int leftconcat[2 * 100000][11];
long long int eighteen = 1000000000000000000;
int main() {
  long long int n, k, i, j;
  cin >> n >> k;
  map<pair<long long int, long long int>, long long int> m;
  long long int temp, dig, mul;
  pair<long long int, long long int> p;
  for (i = 0; i < n; i++) {
    cin >> a[i].first;
    temp = a[i].first;
    dig = 0;
    while (temp > 0) {
      temp /= 10;
      dig++;
    }
    a[i].second = dig;
    p.first = a[i].first % k;
    p.second = a[i].second;
    m[p]++;
  }
  long long int anamoly;
  for (i = 0; i < n; i++) {
    mul = 1;
    for (j = 1; j <= 10; j++) {
      mul *= 10;
      if (j == 10 && a[i].second == 10) {
        anamoly = eighteen % k;
        for (int z = 0; z < 10; z++) {
          leftconcat[i][j] = (leftconcat[i][j] + anamoly) % k;
        }
      } else
        leftconcat[i][j] =
            ((unsigned long long)mul * (unsigned long long)a[i].first) % k;
    }
  }
  long long int req, ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 1; j <= 10; j++) {
      req = (k - leftconcat[i][j]) % k;
      p.first = req;
      p.second = j;
      if (m.find(p) != m.end()) ans += m[p];
      if (a[i].second == j && a[i].first % k == req) ans--;
    }
  }
  cout << ans;
}
