#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("");
}
