#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, id;
};
int used[200000];
vector<Edge> G[200000];
int vis[200000];
vector<vector<int>> ans;
int dfs(int v, int p) {
  if (vis[v]) return -1;
  vis[v] = 1;
  int remc = -1;
  for (auto e : G[v]) {
    if (e.to == p || used[e.id]) continue;
    used[e.id] = 1;
    int res = dfs(e.to, v);
    if (res == -1) {
      if (remc == -1) {
        remc = e.to;
      } else {
        ans.push_back({remc, v, e.to});
        remc = -1;
      }
    } else {
      ans.push_back({res, e.to, v});
    }
  }
  return remc;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    G[a].push_back({b, i});
    G[b].push_back({a, i});
  }
  for (int i = 0; i < N; i++) {
    if (!vis[i]) dfs(i, -1);
  }
  printf("%d\n", ans.size());
  for (auto a : ans) {
    printf("%d %d %d\n", a[0] + 1, a[1] + 1, a[2] + 1);
  }
}
