#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e5 + 10;
vector<pair<int, int>> g[MAXN];
bool used[MAXN];
bool edge[MAXN];
struct path {
  int x, y, z;
};
vector<path> ans;
bool dfs(int u, int p) {
  used[u] = 1;
  int x = 0;
  for (auto e : g[u]) {
    int v = e.first;
    bool ok2 = 0;
    if (!used[v])
      ok2 = dfs(v, u);
    else
      ok2 = 1;
    if (ok2 && v != p && !edge[e.second]) {
      if (!x)
        x = v;
      else {
        ans.push_back({x, u, v});
        x = 0;
      }
      edge[e.second] = 1;
    }
  }
  if (x && p != -1) ans.push_back({x, u, p});
  return !x;
}
int main() {
  int n, m;
  cin >> n >> m;
  int num = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back({v, num});
    g[v].push_back({u, num++});
  }
  for (int u = 1; u <= n; u++)
    if (!used[u]) dfs(u, -1);
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i.x << " " << i.y << " " << i.z << "\n";
  return 0;
}
