#include <bits/stdc++.h>
const int M = 200005;
int read() {
  int x = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * flag;
}
int n, m, tot = 1, cnt, f[M], p[M], vis[M], a[M], b[M], c[M];
struct edge {
  int v, next;
  edge(int V = 0, int N = 0) : v(V), next(N) {}
} e[2 * M];
void dfs(int u) {
  vis[u] = 1;
  for (int i = f[u]; i; i = e[i].next) {
    int v = e[i].v;
    e[i].v = e[i ^ 1].v = 0;
    if (v) {
      if (!vis[v]) dfs(v);
      if (p[v])
        a[++cnt] = u, b[cnt] = v, c[cnt] = p[v], p[v] = 0;
      else if (p[u])
        a[++cnt] = v, b[cnt] = u, c[cnt] = p[u], p[u] = 0;
      else
        p[u] = v;
    }
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    e[++tot] = edge(v, f[u]), f[u] = tot;
    e[++tot] = edge(u, f[v]), f[v] = tot;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) {
    printf("%d %d %d\n", a[i], b[i], c[i]);
  }
}
