#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, tot, vis[N], used[N];
vector<int> g[N], es[N];
struct Node {
  int x, y, z;
  Node() {}
  Node(int x, int y, int z) : x(x), y(y), z(z) {}
} res[N];
void dfs(int u, int par) {
  vis[u] = 1;
  for (auto v : g[u])
    if (!vis[v]) dfs(v, u);
  pair<int, int> pre = make_pair(0, 0);
  int pid = 0;
  for (int i = 0; i < g[u].size(); i++) {
    if (g[u][i] == par) {
      pid = es[u][i];
      continue;
    }
    if (used[es[u][i]]) continue;
    if (pre.first) {
      res[tot++] = Node(pre.second, u, g[u][i]);
      used[pre.first] = used[es[u][i]] = 1;
      pre.first = 0;
    } else {
      pre = make_pair(es[u][i], g[u][i]);
    }
  }
  if (pre.first && par) {
    res[tot++] = Node(pre.second, u, par);
    used[pid] = used[pre.first] = 1;
  }
}
void solve() {
  scanf("%d%d", &n, &m);
  for (int _ = 1; _ <= m; _++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    es[u].push_back(_);
    es[v].push_back(_);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  printf("%d\n", tot);
  for (int i = 0; i < tot; i++)
    printf("%d %d %d\n", res[i].x, res[i].y, res[i].z);
}
int main() {
  solve();
  return 0;
}
