#include <bits/stdc++.h>
using namespace std;
int n, m, t, ans, x, y;
int nxt[1100000], h[1100000], to[1100000], v[1100000], f[1100000], a[1100000],
    b[1100000], c[1100000];
void add(int x, int y) {
  nxt[t] = h[x];
  h[x] = t;
  to[t++] = y;
}
void dfs(int x) {
  v[x] = 1;
  for (int e = h[x]; ~e; e = nxt[e]) {
    int y = to[e];
    to[e] = to[e ^ 1] = 0;
    if (y) {
      if (!v[y]) dfs(y);
      if (f[y]) {
        a[++ans] = x;
        b[ans] = y;
        c[ans] = f[y];
        f[y] = 0;
      } else if (f[x]) {
        a[++ans] = f[x];
        b[ans] = x;
        c[ans] = y;
        f[x] = 0;
      } else
        f[x] = y;
    }
  }
}
signed main() {
  memset(h, -1, sizeof(h));
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  v[0] = 1;
  for (int i = 1; i <= n; i++)
    if (!v[i]) dfs(i);
  cout << ans << endl;
  for (int i = 1; i <= ans; i++) printf("%d %d %d\n", a[i], b[i], c[i]);
  return 0;
}
