#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <typename T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
  bool first = true;
  os << "{";
  for (unsigned int i = 0; i < v.size(); i++) {
    if (!first) os << ",";
    os << v[i];
    first = false;
  }
  return os << "}";
}
template <typename T>
inline ostream& operator<<(ostream& os, const set<T>& v) {
  bool first = true;
  os << "{";
  for (typename set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) {
    if (!first) os << ",";
    os << *ii;
    first = false;
  }
  return os << "}";
}
template <typename T>
inline ostream& operator<<(ostream& os, const multiset<T>& v) {
  bool first = true;
  os << "{";
  for (typename multiset<T>::const_iterator ii = v.begin(); ii != v.end();
       ++ii) {
    if (!first) os << ",";
    os << *ii;
    first = false;
  }
  return os << "}";
}
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, const map<T1, T2>& v) {
  bool first = true;
  os << "{";
  for (typename map<T1, T2>::const_iterator ii = v.begin(); ii != v.end();
       ++ii) {
    if (!first) os << ",";
    os << *ii;
    first = false;
  }
  return os << "}";
}
template <typename T>
bool isPrime(T n) {
  T i, lmt = sqrt(n);
  for (i = 2; i <= lmt; i++)
    if (n % i == 0) return false;
  return true;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T>
T BigMod(T b, T p, T m) {
  if (p == 0)
    return 1 % m;
  else if (p & 1)
    return ((b % m) * (BigMod(b, p - 1, m) % m)) % m;
  else {
    T s = BigMod(b, p / 2, m);
    return ((s % m) * (s % m)) % m;
  }
}
template <typename T>
T power(T b, T p) {
  if (p == 0)
    return 1;
  else if (p & 1)
    return b * power(b, p - 1);
  else {
    T ret = power(b, p / 2);
    return ret * ret;
  }
}
template <typename T>
T ModInv(T b, T m) {
  if (isPrime(b))
    return BigMod(b, m - 2, m) % m;
  else if (gcd(b, m) == 1)
    return BigMod(b, m - 1, m) % m;
}
template <typename T>
T egcd(T a, T b, T& x, T& y) {
  T d;
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  } else {
    T x1, y1;
    d = egcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
  }
  return d;
}
int toint(string s) {
  int i, j, l;
  int num;
  l = s.size();
  for (i = l - 1, j = 0, num = 0; i >= 0; i--, j++) {
    num += (s[i] - 48) * power(10, j);
  }
  return num;
}
const double pi = acos(-1);
const int inf = (1 << 30);
const long long INF = (1LL << 62) - 1;
const int mod = (int)1e9 + 7;
const long long MOD = (long long)1e9 + 7;
const double EPS = 1e-9;
const int dx8[] = {-1, 0, +1, -1, +1, -1, 0, +1};
const int dy8[] = {+1, +1, +1, 0, 0, -1, -1, -1};
const int dx4[] = {0, -1, +1, 0};
const int dy4[] = {+1, 0, 0, -1};
const int dx2[] = {+1, 0};
const int dy2[] = {0, +1};
const int dxkn[] = {1, -1, 1, -1, 2, -2, -2, 2};
const int dykn[] = {2, 2, -2, -2, 1, 1, -1, -1};
vector<long long> val[12];
long long a[200009];
long long md[200009];
long long p[11] = {1,           10LL,         100LL,        1000LL,
                   10000LL,     100000LL,     1000000LL,    10000000LL,
                   100000000LL, 1000000000LL, 10000000000LL};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  unsigned long long k, ans, num, len, m;
  int n, i, j, l, r;
  cin >> n >> k;
  for (i = 1; i < 11; i++) {
    p[i] %= k;
  }
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    md[i] = a[i] % k;
    for (j = 1; j <= 10; j++) {
      val[j].push_back((md[i] * p[j]) % k);
    }
  }
  for (i = 1; i < 11; i++) {
    sort(val[i].begin(), val[i].end());
  }
  for (i = 1, ans = 0LL; i <= n; i++) {
    num = a[i];
    len = 0;
    while (num) {
      len++;
      num /= 10LL;
    }
    m = md[i];
    if (md[i]) m = k - m;
    l = lower_bound(val[len].begin(), val[len].end(), m) - val[len].begin();
    r = upper_bound(val[len].begin(), val[len].end(), m) - val[len].begin();
    ans += (r - l);
    if ((md[i] * p[len] + md[i]) % k == 0) {
      ans--;
    }
  }
  cout << ans << "\n";
  return 0;
}
