#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct Edge {
  int to, next;
} edge[maxn << 2];
int head[maxn], n, m, cnt = 1, f[maxn], vis[maxn], ans, a[maxn], b[maxn],
                      c[maxn];
void Add(int u, int v) {
  edge[++cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt;
}
void Dfs(int rt) {
  vis[rt] = 1;
  for (int i = head[rt]; i; i = edge[i].next) {
    int v = edge[i].to;
    edge[i].to = edge[i ^ 1].to = 0;
    if (v) {
      if (!vis[v]) Dfs(v);
      if (f[v])
        a[++ans] = rt, b[ans] = v, c[ans] = f[v], f[v] = 0;
      else if (f[rt])
        a[++ans] = f[rt], b[ans] = rt, c[ans] = v, f[rt] = 0;
      else
        f[rt] = v;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    Add(u, v);
    Add(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) Dfs(i);
  Dfs(1);
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) printf("%d %d %d\n", a[i], b[i], c[i]);
}
