#include <bits/stdc++.h>
const int MAX_LEN = 1010;
using namespace std;
template <typename U, typename V>
string to_string(pair<U, V>);
string to_string(const string& e_) { return "\"" + e_ + "\""; }
string to_string(char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string(bool e_) { return e_ ? "true" : "false"; }
template <typename T>
string to_string(T e_) {
  string s_ = "[ ";
  for (const auto& x_ : e_) s_ += to_string(x_) + " ";
  return s_ + "]";
}
template <typename U, typename V>
string to_string(pair<U, V> e_) {
  return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str() { ; }
template <typename U, typename... V>
void dbg_str(U u, V... v) {
  ;
  dbg_str(v...);
}
const int N = 2e5 + 20;
int n, k, x, y, cur, ans;
int color[N];
bool vis[N];
int d[N];
int p[N];
vector<int> degree;
vector<vector<int> > adj;
vector<pair<int, int> > edges;
map<pair<int, int>, int> color_edges;
void dfs(int s) {
  vis[s] = true;
  for (int i = 0; i < (int)adj[s].size(); i++) {
    int v = adj[s][i];
    if (v != p[s]) {
      p[v] = s;
      cur++;
      if (cur == ans + 1) cur = 1;
      if (cur == color[p[v]]) cur++;
      if (cur == ans + 1) cur = 1;
      color[v] = cur;
      color_edges[pair<int, int>(s, v)] = cur;
      color_edges[pair<int, int>(v, s)] = cur;
    }
  }
  for (int i = 0; i < (int)adj[s].size(); i++) {
    int v = adj[s][i];
    if (v != p[s] && !vis[v]) dfs(v);
  }
}
int main() {
  scanf("%d %d", &n, &k);
  adj.assign(n + 1, vector<int>(0));
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
    d[x]++;
    d[y]++;
    edges.push_back(pair<int, int>(x, y));
  }
  for (int i = 1; i <= n; i++) degree.push_back(d[i]);
  sort(degree.begin(), degree.end());
  ans = degree[n - 1];
  ;
  while (true) {
    if (ans == 0) break;
    int greater_degree_v =
        upper_bound(degree.begin(), degree.end(), ans - 1) - degree.begin();
    ;
    greater_degree_v = n - greater_degree_v;
    if (greater_degree_v <= k) {
      ans--;
    } else
      break;
  }
  color[1] = -1;
  cur = 0;
  dfs(1);
  printf("%d\n", ans);
  for (int i = 0; i < n - 1; i++) printf("%d ", color_edges[edges[i]]);
}
