#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, cnt, ans;
int t[1100000], nxt[1100000], to[1100000];
int a[1100000], b[1100000], c[1100000], f[1100000];
int vis[1100000];
void add(int u, int v) { nxt[cnt] = t[u], t[u] = cnt, to[cnt++] = v; }
void dfs(int x) {
  vis[x] = true;
  for (int e = t[x]; ~e; e = nxt[e]) {
    int y = to[e];
    to[e] = to[e ^ 1] = 0;
    if (y) {
      if (!vis[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;
    }
  }
}
int main() {
  memset(t, 0xff, sizeof(t));
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> u >> v, add(u, v), add(v, u);
  vis[0] = true;
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i);
  printf("%d\n", ans);
  for (int i = 1; i <= ans; ++i) printf("%d %d %d\n", a[i], b[i], c[i]);
  return 0;
}
