#include <bits/stdc++.h>
using namespace std;
const int maxN = 200001;
vector<int> G[maxN];
int in[maxN], inctr;
struct Three {
  int a, b, c;
  Three(int e = 0, int f = 0, int g = 0) : a(e), b(f), c(g) {}
};
vector<Three> res;
void f(int& dep, int newv, int v) {
  if (dep == 0)
    dep = newv;
  else
    res.push_back(Three(dep, v, newv)), dep = 0;
}
bool dfs(int v, int father) {
  in[v] = ++inctr;
  int dep = 0;
  for (int u : G[v]) {
    if (u == father or in[u] > in[v]) continue;
    if (in[u] != 0) {
      f(dep, u, v);
      continue;
    }
    if (dfs(u, v)) f(dep, u, v);
  }
  if (father != 0) f(dep, father, v);
  return dep != 0;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (in[i] == 0) dfs(i, 0);
  printf("%d\n", (int)res.size());
  for (Three t : res) printf("%d %d %d\n", t.a, t.b, t.c);
  return 0;
}
