#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
struct Dinic {
  int n, m, h[10005], l[10005], s, t, w[10005];
  struct eg {
    int v, c, f, x;
  } e[(10005 * 4)];
  bool bfs() {
    static int q[10005];
    for (int i(0); i < n; i++) l[i] = -1;
    int B(l[s] = 0), E(1);
    q[0] = s;
    while (B < E)
      for (int k(q[B++]), i(h[k]); ~i; i = e[i].x)
        if (e[i].f < e[i].c && !~l[e[i].v])
          l[e[i].v] = l[k] + 1, q[E++] = e[i].v;
    return ~l[t];
  }
  int dfs(int u, int f) {
    if (u == t) return f;
    int mf;
    for (int i(w[u]); ~i; i = e[i].x)
      if (e[i].f < e[i].c && l[u] + 1 == l[e[i].v])
        if ((mf = dfs(e[i].v, min(f, e[i].c - e[i].f))) > 0)
          return e[i].f += mf, e[i ^ 1].f -= mf, mf;
    return 0;
  }
  void ini(int N, int f, int d) {
    n = N;
    s = f;
    t = d;
    m = 0;
    for (int i(0); i < n; i++) h[i] = -1;
  }
  int ade(int u, int v, int c = 1, int rc = 0) {
    e[m] = eg{v, c, 0, h[u]};
    h[u] = m++;
    e[m] = eg{u, rc, 0, h[v]};
    h[v] = m++;
    return m - 2;
  }
  int mf() {
    int a(0), d;
    while (bfs()) {
      memcpy(w, h, sizeof(int) * n);
      do a += d = dfs(s, int(1e9 + 1));
      while (d);
    }
    return a;
  }
} H;
int N, M, A[10005], B[10005], a, I[10005], f[10005], G[10005], C[10005];
bool ok(int t) {
  H.ini(((N + M) + 1) + 1, (N + M), ((N + M) + 1));
  for (int i(0); i < M; i++) H.ade((N + M), i);
  for (int i(0); i < N; i++) H.ade(M + i, ((N + M) + 1), t);
  for (int i(0); i < M; i++) I[i] = H.ade(i, A[i] + M), H.ade(i, B[i] + M);
  return H.mf() == M;
}
bool OK(int t) {
  memcpy(G, f, sizeof(f)), (memset(C, 0, sizeof(C)));
  int F = 0, x, O = 0;
  H.ini(((N + M) + 1) + 1, (N + M), ((N + M) + 1));
  for (int i(0); i < M; i++) H.ade((N + M), i);
  for (int i(0); i < N; i++) H.ade(M + i, ((N + M) + 1), t);
  while (666) {
    x = 0;
    for (int i(0); i < M; i++) {
      if (C[i]) continue;
      if (G[A[i]] > t && G[B[i]] > t)
        ;
      else
        --G[A[i]], --G[B[i]], ++C[i], x = 1;
    }
    if (!x) break;
  }
  for (int i(0); i < M; i++)
    if (G[A[i]] > t && G[B[i]] > t) H.ade(i, A[i] + M), H.ade(i, B[i] + M), ++F;
  for (int i(0); i < N; i++) O += G[i] > t;
  if (O * t < F) return 0;
  return H.mf() == F;
}
int bs(int B = 0, int E = int(1e9 + 1)) {
  int M;
  while (B < E)
    if (OK(M = (B + E) >> 1))
      E = M;
    else
      B = M + 1;
  return B;
}
int hup() {
  memcpy(G, f, sizeof(f)), (memset(C, 0, sizeof(C)));
  for (int i(0); i < M; i++)
    if (G[A[i]] < G[B[i]])
      ++C[A[i]], --G[B[i]];
    else
      ++C[B[i]], --G[A[i]];
  return *max_element(C, C + N);
}
int main(void) {
  scanf("%d%d", &N, &M);
  for (int i(0); i < M; i++)
    scanf("%d%d", A + i, B + i), ++f[--A[i]], ++f[--B[i]];
  a = bs(0, hup()), printf("%d\n", a), ok(a);
  for (int i(0); i < M; i++)
    if (!H.e[I[i]].f)
      printf("%d %d\n", B[i] + 1, A[i] + 1);
    else
      printf("%d %d\n", A[i] + 1, B[i] + 1);
  return 0;
}
