#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m, cnt, h[200005], X[200005], Y[200005], dep[200005], du[200005], Tot,
    col[200005], ans[200005];
struct Edge {
  int to, next;
} a[200005 * 2];
inline void Add(int x, int y) {
  cnt++;
  a[cnt].to = y;
  a[cnt].next = h[x];
  h[x] = cnt;
}
void dfs(int x, int fa, int ban) {
  dep[x] = dep[fa] + 1;
  int now = 1;
  if (ban == Tot)
    for (int i = h[x]; i; i = a[i].next) {
      int y = a[i].to;
      if (y != fa) {
        ans[y] = now;
        dfs(y, x, now);
        now = min(now + 1, Tot - 1);
        if (!now) now = 1;
      }
    }
  else
    for (int i = h[x]; i; i = a[i].next) {
      int y = a[i].to;
      if (y != fa) {
        if (now == ban) now++;
        ans[y] = now;
        dfs(y, x, now);
        now = min(now + 1, Tot);
      }
    }
}
bool check(int lim) {
  int sum = 0;
  for (int i = 1; i <= n; ++i) sum += (du[i] > lim);
  return sum <= m;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i < n; ++i) {
    int x = read(), y = read();
    X[i] = x;
    Y[i] = y;
    Add(x, y);
    Add(y, x);
    du[x]++;
    du[y]++;
  }
  int l = 1, r = n, mid;
  while (l <= r) {
    mid = l + r >> 1;
    if (check(mid))
      r = mid - 1, Tot = mid;
    else
      l = mid + 1;
  }
  dfs(1, 0, 0);
  cout << Tot << '\n';
  for (int i = 1; i < n; ++i) {
    if (dep[X[i]] > dep[Y[i]])
      cout << ans[X[i]] << ' ';
    else
      cout << ans[Y[i]] << ' ';
  }
}
