#include <iostream>
using namespace std;

typedef long long LL;

const int N = 10010;

LL a[N];

LL judge(int x)
{
    LL len = 0, t = 1;

    while (x)
    {
        x /= 10;
        len++;
    }

    for (int i = 1; i <= len; i++)
        t *= 10;
    return t;
}

int main()
{
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    LL ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
        {
            LL p = judge(a[i]), q = judge(a[j]);

            LL x = a[i] * q + a[j];
            LL y = a[j] * p + a[i];

            if (x % k == 0)
                ans++;
            if (y % k == 0)
                ans++;
        }

    cout << ans << endl;
    return 0;
}
