#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct edg {
  int to, id;
};
vector<edg> vec[maxn];
int n, k;
int p, q;
int ans;
int res[maxn];
int du[maxn];
void dfs(int x, int f, int val) {
  int cnt = 0;
  for (int i = 0; i < vec[x].size(); i++) {
    edg kk = vec[x][i];
    if (kk.to == f) continue;
    cnt++;
    if (cnt == val) cnt++;
    if (cnt > ans) cnt--;
    res[kk.id] = cnt;
    dfs(kk.to, x, cnt);
  }
}
bool check(int x) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (du[i] > x) res++;
  }
  if (res <= k) return true;
  return false;
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= n - 1; i++) {
    p = read();
    q = read();
    vec[p].push_back((edg){q, i});
    vec[q].push_back((edg){p, i});
    du[p]++;
    du[q]++;
  }
  int l = 1, r = n;
  ans = n + 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      ans = min(ans, mid), r = mid - 1;
    else
      l = mid + 1;
  }
  dfs(1, 0, 0);
  cout << ans << "\n";
  for (int i = 1; i <= n - 1; i++) {
    cout << res[i] << " ";
  }
}
