#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897;
const long long mod = 1000000007LL;
const long long INF = 1e18;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n, k, u, v, d = 0;
  cin >> n >> k;
  vector<vector<pair<long long, long long> > > g(
      n, vector<pair<long long, long long> >());
  vector<long long> ra(n), da(n);
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--, v--;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
    da[u]++;
    da[v]++;
  }
  function<void(long long, long long, long long)> dfs =
      [&](long long u, long long v, long long c) {
        long long co = 0;
        for (auto i : g[u]) {
          if (i.first == v) continue;
          if (co == c) {
            co = (co + 1) % d;
            c = -1;
          }
          ra[i.second] = co;
          dfs(i.first, u, co);
          co = (co + 1) % d;
        }
      };
  map<long long, long long> mp;
  for (long long i : da) {
    mp[i]++;
  }
  long long ke = n;
  for (auto i : mp) {
    if (ke > k) {
      d = i.first;
      ke -= i.second;
    } else {
      break;
    }
  }
  dfs(0, -1, -1);
  cout << d << "\n";
  for (long long i = 0; i < n - 1; i++) {
    cout << (ra[i] + 1) << " ";
  }
  return 0;
}
