#include <bits/stdc++.h>
using namespace std;
const int MaxN(200003);
int Tid[MaxN], Index;
vector<int> G[MaxN];
vector<tuple<int, int, int> > ans;
bool dfs(int u, int fa) {
  Tid[u] = ++Index;
  int d = 0, nd, ls;
  for (auto v : G[u])
    if (v != fa) {
      if (!Tid[v])
        nd = dfs(v, u);
      else
        nd = Tid[v] > Tid[u];
      if (!nd) continue;
      if (d) ans.emplace_back(ls, u, v);
      d ^= 1, ls = v;
    }
  if (d && fa) {
    ans.emplace_back(fa, u, ls);
    return false;
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!Tid[i]) dfs(i, 0);
  printf("%d\n", ans.size());
  for (auto i : ans) {
    int x, y, z;
    tie(x, y, z) = i;
    printf("%d %d %d\n", x, y, z);
  }
  return 0;
}
