#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
char mem[255 * 1000 * 1000];
int mpos = 0;
void *operator new(size_t n) { return mem + (mpos += n) - n; }
void operator delete(void *) {}
const long long N = 12;
long long n, k;
vector<long long> arr;
vector<long long> mylog;
unordered_map<long long, long long> cnt[N];
long long ans = 0;
void solve() {
  for (int i = 0; i < N; ++i) cnt[i].clear();
  for (int i = 0; i < n; ++i) {
    long long ind = k - arr[i];
    for (int j = 0; j < N; ++j) {
      if (cnt[j].count(ind)) ans += cnt[j][ind];
      ind = (ind * 10) % k;
    }
    ++cnt[mylog[i]][arr[i] == k ? 0 : arr[i]];
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  srand(time(NULL));
  cin >> n >> k;
  arr = mylog = vector<long long>(n);
  for (auto &i : arr) cin >> i;
  for (int i = 0; i < n; ++i) mylog[i] = int(to_string(arr[i]).size());
  for (auto &i : arr) i = (i - 1) % k + 1;
  solve();
  reverse((arr).begin(), (arr).end());
  reverse((mylog).begin(), (mylog).end());
  solve();
  cout << ans;
  return 0;
}
