#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
struct node {
  int x, y, z;
} ans[N];
int tot, f[N], vis[N], fl[N];
vector<pair<int, int>> e[N];
void dfs(int u) {
  vis[u] = 1;
  for (auto p : e[u]) {
    int v = p.first, id = p.second;
    if (fl[id]) continue;
    fl[id] = 1;
    if (!vis[v]) dfs(v);
    if (f[v])
      ans[++tot] = {u, v, f[v]}, f[v] = 0;
    else if (f[u])
      ans[++tot] = {f[u], u, v}, f[u] = 0;
    else
      f[u] = v;
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    e[u].push_back({v, i}), e[v].push_back({u, i});
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i);
  cout << tot << "\n";
  for (int i = 1; i <= tot; ++i)
    cout << ans[i].x << " " << ans[i].y << " " << ans[i].z << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
