#include <bits/stdc++.h>
const int N = 2e5 + 10;
int head[N], to[N << 1], Next[N << 1], cnt = 1;
void add(int u, int v) { to[++cnt] = v, Next[cnt] = head[u], head[u] = cnt; }
int used[N << 1], ans[N << 2], n, m, tot, vis[N];
void dfs(int now, int fa, int edg) {
  vis[now] = 1;
  std::vector<int> ch;
  for (int i = head[now]; i; i = Next[i]) {
    int v = to[i];
    if (v != fa && !vis[v]) dfs(v, now, i);
  }
  for (int i = head[now]; i; i = Next[i]) {
    int v = to[i];
    if (v != fa && !used[i]) {
      ch.push_back(i);
      used[i ^ 1] = 1;
    }
  }
  for (int i = 0; i < ch.size(); i++) {
    if (i & 1) ans[++tot] = now;
    ans[++tot] = to[ch[i]];
  }
  if (ch.size() & 1) {
    if (fa)
      ans[++tot] = now, ans[++tot] = fa, used[edg] = 1;
    else
      tot--;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = 1; i <= m; i++) scanf("%d%d", &u, &v), add(u, v), add(v, u);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0, 0);
  printf("%d\n", tot / 3);
  for (int i = 1; i <= tot; i++) {
    printf("%d ", ans[i]);
    if (i % 3 == 0) printf("\n");
  }
  return 0;
}
