'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;
let sigintCalled = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

process.on('SIGINT', function() {
    ++sigintCalled;
        console.log(`SIGINT ${sigintCalled}`);
    if (sigintCalled >= 2) {
        process.exit(1);
        return;
    }

    inputString = inputString.split('\n');

    main();
    process.exit(0);
});

function readLine() {
    return inputString[currentLine++];
}

/*
 * Complete the 'nonDivisibleSubset' function below.
 *
 * The function is expected to return an INTEGER.
 * The function accepts following parameters:
 *  1. INTEGER k
 *  2. INTEGER_ARRAY s
 */

function nonDivisibleSubset(k, s) {
    if (sigintCalled >= 2) {
        process.exit(1);
        return null;
    }
    
    console.log('k', k, 's', s);

    if (s.length <= 1) {
        return s.length;
    }

    let el = s[0];
    // with
    let msize1 = nonDivisibleSubset(
        k,
        s.slice(1).filter((a) => {
            return (a + el) % k !== 0
        })
    ) + 1;
    // or without

    let msize2 = nonDivisibleSubset(k, s.slice(1));
    return Math.max(msize1, msize2);
}

function main() {
    const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const firstMultipleInput = readLine().replace(/\s+$/g, '').split(' ');

    const n = parseInt(firstMultipleInput[0], 10);

    const k = parseInt(firstMultipleInput[1], 10);

    const s = readLine().replace(/\s+$/g, '').split(' ').map(sTemp => parseInt(sTemp, 10));

    const result = nonDivisibleSubset(k, s);

    console.log(`Result ${result}`);

    ws.write(result + '\n');

    ws.end();
}
