#include <iostream>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
using namespace std;
const long long MaxLL = (long long)1e18;
const int maxInt = (int)1e9, maxN = (int)1e5 + 228;
pair<int, int> a[maxN];
vector<int> b;
int ans[maxN], i, j, n, m;
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
cin >> n >> m;
for(i = 0; i < n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a, a + n);
for(i = 0; i < n; i++) {
for(j = 0; j < b.size(); j++) {
if(a[i].first - b[j] > m) break;
}
ans[a[i].second] = j + 1;
if(j == b.size()) b.push_back(0);
b[j] = a[i].first;
}
cout << b.size() << "\n";
for(i = 0; i < n; i++) {
cout << ans[i] << " ";
}
puts("");
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWF0aC5oPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGlvbWFuaXA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGxvbmcgbG9uZyBNYXhMTCA9IChsb25nIGxvbmcpMWUxODsKY29uc3QgaW50IG1heEludCA9IChpbnQpMWU5LCBtYXhOID0gKGludCkxZTUgKyAyMjg7CgpwYWlyPGludCwgaW50PiBhW21heE5dOwp2ZWN0b3I8aW50PiBiOwppbnQgYW5zW21heE5dLCBpLCBqLCBuLCBtOwoKaW50IG1haW4oKSB7Ci8vCWZyZW9wZW4oIi5pbiIsICJyIiwgc3RkaW4pOwovLwlmcmVvcGVuKCIub3V0IiwgInciLCBzdGRvdXQpOwoKCWNpbiA+PiBuID4+IG07Cglmb3IoaSA9IDA7IGkgPCBuOyBpKyspIHsKCQljaW4gPj4gYVtpXS5maXJzdDsKCQlhW2ldLnNlY29uZCA9IGk7Cgl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