#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, inf = 1e9 + 7;
int n, k, is[N], vis[N], in[N], col[N], o[N];
vector<int> adj[N];
map<pair<int, int>, int> m;
void dfs(int id, int c) {
  vis[id] = 1;
  int cur = 1;
  for (auto i : adj[id]) {
    if (cur == c) cur++;
    if (!col[m[pair<int, int>(i, id)]]) {
      col[m[pair<int, int>(i, id)]] = cur;
      if (is[i] && !vis[i]) dfs(i, cur);
      cur++;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, a, b, ans = 0;
  cin >> n >> k;
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
    m[pair<int, int>(a, b)] = m[pair<int, int>(b, a)] = i;
    in[a]++;
    in[b]++;
    o[i] = i;
  }
  o[n] = n;
  sort(o + 1, o + n + 1, [](int a, int b) { return in[a] < in[b]; });
  cout << in[o[n - k]] << "\n";
  for (i = 1; i <= n - k; i++) is[o[i]] = 1;
  for (i = 1; i <= n - k; i++)
    if (!vis[o[i]]) dfs(o[i], 0);
  for (i = n - k + 1; i <= n; i++) {
    for (auto j : adj[o[i]])
      if (!col[m[pair<int, int>(o[i], j)]]) col[m[pair<int, int>(o[i], j)]] = 1;
  }
  for (i = 1; i < n; i++) cout << col[i] << " ";
}
