#include <bits/stdc++.h>
using namespace std;
const int MAX = 200001;
int n, k;
map<pair<int, int>, int> Rp;
vector<vector<int>> adj(MAX);
bool possible(int r, vector<int> &R) {
  queue<int> Q;
  vector<int> D(n + 1, -1), P(n + 1, -1);
  Q.emplace(1);
  int kk = 0;
  while (!Q.empty()) {
    int c = Q.front();
    Q.pop();
    if (adj[c].size() > r) {
      kk++;
      if (kk > k) return false;
    }
    int d = 0, co = -1;
    for (int i : adj[c]) {
      if (i != P[c]) {
        co = (co + 1) % r;
        if (co == D[c] && !d) {
          d = 1;
          co = (co + 1) % r;
        }
        D[i] = co;
        R[Rp[{min(i, c), max(i, c)}]] = co + 1;
        Q.emplace(i);
        P[i] = c;
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cin >> n >> k;
  int x, y;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    Rp[{min(x, y), max(x, y)}] = i - 1;
  }
  int res = n, hi = n, lo = 1;
  vector<int> Res(n - 1), R(n - 1);
  while (lo <= hi) {
    int md = (lo + hi) >> 1;
    if (possible(md, R)) {
      Res = R;
      res = md;
      hi = md - 1;
    } else {
      lo = md + 1;
    }
  }
  cout << res << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << Res[i] << ' ';
  }
  return 0;
}
