#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
struct Edge {
  int to, next;
} edge[maxn * 2];
int k, head[maxn];
void add(int a, int b) {
  edge[k].to = b;
  edge[k].next = head[a];
  head[a] = k++;
}
int dep[maxn], vedge[maxn * 2], fa[maxn], used[maxn * 2];
int x[maxn], y[maxn], z[maxn], cnt;
void dfs(int u, int pre) {
  fa[u] = pre;
  int tag = -1;
  int id = 0;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int to = edge[i].to;
    if (to == pre) continue;
    if (!dep[to]) {
      dep[to] = dep[u] + 1;
      dfs(to, u);
      dep[to] = dep[u] + 1;
      vedge[i] = 1;
    }
  }
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int to = edge[i].to;
    if (used[i]) continue;
    if (to == pre) {
      tag = i;
      continue;
    }
    if (id == 0) {
      id = to;
    } else {
      x[++cnt] = id;
      y[cnt] = u;
      z[cnt] = to;
      id = 0;
    }
    used[i] = used[i ^ 1] = 1;
  }
  if (id && tag != -1) {
    used[tag] = used[tag ^ 1] = 1;
    x[++cnt] = id;
    y[cnt] = u;
    z[cnt] = fa[u];
  }
}
int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) head[i] = -1;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b);
    add(b, a);
  }
  for (int i = 1; i <= n; i++) {
    if (!dep[i]) {
      dep[i] = 1;
      dfs(i, 0);
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) {
    printf("%d %d %d\n", x[i], y[i], z[i]);
  }
  return 0;
}
