#include <bits/stdc++.h>
using namespace std;
int mod, arr[200008], brr[200008], crr[200008];
std::vector<int> v[13];
int main() {
  mod = 1000000007;
  int t = 1;
  while (t--) {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &arr[i]);
      int cnt = 0;
      int a = arr[i];
      while (a) {
        cnt++;
        a /= 10;
      }
      brr[i] = cnt;
      crr[i] = arr[i] % k;
      v[brr[i]].push_back(crr[i]);
    }
    for (int i = 1; i <= 10; i++) sort(v[i].begin(), v[i].end());
    long long int ans = 0;
    for (int i = 1; i <= n; i++) {
      int cnt = brr[i];
      long long int a1 = crr[i];
      for (int j = 1; j <= 10; j++) {
        a1 = (a1 * 10) % k;
        int a = k - a1;
        if (a1 == 0) a = 0;
        int l = lower_bound(v[j].begin(), v[j].end(), a) - v[j].begin();
        int r = upper_bound(v[j].begin(), v[j].end(), a) - v[j].begin();
        ans += r - l;
        if (j == cnt && ((crr[i]) == (a))) ans--;
      }
    }
    printf("%lld\n", ans);
  }
}
