#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct node {
  int num, color, next;
} path[2 * maxn];
int tot, head[maxn], flagg, n, k, u, v, l, r, mid, ans;
bool vis[maxn];
void addd(int x, int y) {
  tot++;
  path[tot].num = y;
  path[tot].next = head[x];
  head[x] = tot;
}
void dfs(int k, int hp) {
  vis[k] = true;
  int son = head[k];
  int w = 1;
  if (k == 1) w = 0;
  while (son > 0) {
    if (!vis[path[son].num]) {
      w++;
      dfs(path[son].num, hp);
    }
    son = path[son].next;
  }
  if (w > hp) flagg++;
}
void dfs2(int k, int last) {
  vis[k] = true;
  int son = head[k], w = last;
  while (son > 0) {
    if (!vis[path[son].num]) {
      w = w % ans + 1;
      int temp = son + 1;
      if (temp % 2) temp -= 2;
      path[son].color = w;
      path[temp].color = w;
      dfs2(path[son].num, w);
    }
    son = path[son].next;
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    addd(u, v);
    addd(v, u);
  }
  l = 1;
  r = n - 1;
  ans = n - 1;
  while (l <= r) {
    mid = (l + r) >> 1;
    memset(vis, 0, sizeof(vis));
    flagg = 0;
    dfs(1, mid);
    if (flagg <= k) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%d\n", ans);
  memset(vis, 0, sizeof(vis));
  dfs2(1, 0);
  for (int i = 1; i < n; i++) printf("%d ", path[2 * i].color);
  printf("\n");
  return 0;
}
