#include <bits/stdc++.h>
using namespace std;
int v[200005], len[200005];
vector<int> moduls[11];
int64_t ten[11];
inline int calc(int a, int i) {
  return upper_bound(moduls[i].begin(), moduls[i].end(), a) -
         lower_bound(moduls[i].begin(), moduls[i].end(), a);
}
int32_t main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
  }
  ten[0] = 1;
  for (int i = 1; i <= 10; i++) {
    ten[i] = 10ll * ten[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    int tmp = v[i], cnt = 0;
    while (tmp > 0) {
      tmp /= 10;
      cnt++;
    }
    len[i] = cnt;
    moduls[cnt].push_back(v[i] % k);
  }
  for (int i = 1; i <= 10; i++) {
    sort(moduls[i].begin(), moduls[i].end());
  }
  int64_t ans = 0;
  for (int p = 1; p <= n; p++) {
    int a = v[p] % k;
    for (int i = 1; i <= 10; i++) {
      int tmp = ten[i] % k * a % k;
      if (tmp == 0) {
        ans += calc(0, i);
        if (len[p] == i && a == 0) {
          ans--;
        }
      } else {
        ans += calc(k - tmp, i);
        if (len[p] == i && a + tmp == k) {
          ans--;
        }
      }
    }
  }
  cout << ans << endl;
}
