#include <bits/stdc++.h>
using namespace std;
int n, m, t = 1;
set<int> adj[200001];
vector<int> height(200001);
vector<tuple<int, int, int>> ans;
void insert_triple(int a, int b, int c) {
  adj[a].erase(adj[a].find(b));
  adj[b].erase(adj[b].find(a));
  adj[b].erase(adj[b].find(c));
  adj[c].erase(adj[c].find(b));
  ans.emplace_back(a, b, c);
}
void dfs(int now, int prev) {
  height[now] = t++;
  vector<int> v;
  vector<int> ad(adj[now].begin(), adj[now].end());
  for (int u : ad) {
    if (!height[u]) dfs(u, now);
  }
  for (int u : adj[now]) {
    if (height[u] > height[now]) v.push_back(u);
  }
  for (int i = 1; i < v.size(); i += 2) {
    insert_triple(v[i - 1], now, v[i]);
  }
  if (v.size() % 2) {
    if (prev != 0) insert_triple(prev, now, v.back());
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    adj[x].insert(y);
    adj[y].insert(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!height[i]) dfs(i, 0);
  }
  cout << ans.size() << '\n';
  for (auto [u, v, w] : ans) {
    cout << u << ' ' << v << ' ' << w << '\n';
  }
  return 0;
}
