#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
int n, k;
int tot;
vector<pair<int, int> > G[N];
int col[N], du[N], ans[N];
void dfs(int u, int fa_col, int num, int fa) {
  int col_id = 0;
  for (auto it : G[u]) {
    int v = it.first;
    int id = it.second;
    if (v == fa) continue;
    if (col_id == fa_col) col_id = (col_id + 1) % num;
    ans[id] = col_id;
    col_id = (col_id + 1) % num;
    dfs(v, ans[id], num, u);
  }
  return;
}
bool judge(int x) {
  int p = upper_bound(du + 1, du + 1 + n, x) - du;
  if (n - p + 1 > k) return 0;
  dfs(1, -1, x, -1);
  return 1;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(make_pair(v, i));
    G[v].push_back(make_pair(u, i));
    du[u]++;
    du[v]++;
  }
  sort(du + 1, du + 1 + n);
  int l = 1, r = n - 1, res;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (judge(m)) {
      res = m;
      r = m - 1;
    } else
      l = m + 1;
  }
  printf("%d\n", res);
  for (int i = 1; i < n; ++i) printf("%d ", ans[i] + 1);
  return 0;
}
