#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long int MOD = 1e9 + 7, INF = 1e18;
long long int dx[8] = {0, -1, 1, 0, 1, -1, 1, -1},
              dy[8] = {1, 0, 0, -1, -1, -1, 1, 1};
struct edge {
  long long int cost;
  long long int u, v;
};
long long int digit(long long int v) {
  string s = to_string(v);
  return ((long long int)(s).size());
}
long long int N, K;
long long int arr[202000];
map<long long int, long long int> cnt[14];
int main() {
  cin >> N >> K;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    cin >> arr[i];
    cnt[digit(arr[i])][arr[i] % K]++;
  }
  long long int ans = 0;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    long long int curr = 1;
    for (long long int j = (1), j_end_ = (14); j < j_end_; j++) {
      curr *= 10;
      curr %= K;
      long long int dis = K - ((arr[i] * curr) % K);
      dis %= K;
      if (cnt[j].find(dis) != cnt[j].end()) ans += cnt[j][dis];
    }
    long long int p = 1;
    for (long long int j = (0), j_end_ = (digit(arr[i])); j < j_end_; j++) {
      p *= 10;
      p %= K;
    }
    if ((arr[i] * p + arr[i]) % K == 0) ans--;
  }
  cout << ans << '\n';
}
