#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323;
const long long int linf = 1000111000111000111LL;
const long long int inf = 1011111111;
const long long int N = 200005;
vector<long long int> g[N];
bool vis[N];
long long int degcnt[N], ans;
map<pair<long long int, long long int>, long long int> mp1;
void dfs(long long int node, long long int prevclr) {
  vis[node] = true;
  long long int clr = 0;
  for (long long int i = 0; i < (long long int)(g[node]).size(); i++) {
    long long int v = g[node][i];
    if (vis[v] == false) {
      if (clr == prevclr) clr = (clr + 1) % ans;
      mp1[{node, v}] = clr;
      mp1[{v, node}] = clr;
      dfs(v, clr);
      clr = (clr + 1) % ans;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int test = 1;
  while (test--) {
    long long int n, k;
    cin >> n >> k;
    long long int edges[n][2];
    for (long long int i = 0; i < n - 1; i++) {
      long long int u, v;
      cin >> u >> v;
      edges[i][0] = u;
      edges[i][1] = v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    long long int mxdeg = 0;
    for (long long int i = 1; i <= n; i++) {
      degcnt[(long long int)(g[i]).size()]++;
      mxdeg = max(mxdeg, (long long int)(g[i]).size());
    }
    for (long long int i = n; i >= 0; i--) degcnt[i] += degcnt[i + 1];
    for (long long int i = 0; i <= n; i++) {
      if (degcnt[i] <= k) {
        ans = i;
        break;
      }
    }
    ans--;
    dfs(1, -1);
    cout << ans << "\n";
    for (long long int i = 0; i < n - 1; i++) {
      long long int u = edges[i][0];
      long long int v = edges[i][1];
      cout << mp1[{u, v}] + 1 << " ";
    }
  }
  cerr << '\n'
       << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
