#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> dep(n, -1);
  vector<array<int, 3>> ans;
  function<int(int, int, int)> dfs = [&](int x, int fa, int d) {
    dep[x] = d;
    vector<int> tmp;
    for (int to : g[x]) {
      if (to == fa) continue;
      if (dep[to] == -1) {
        int k = dfs(to, x, d + 1);
        if (k) tmp.push_back(to);
      } else if (dep[to] < dep[x]) {
        tmp.push_back(to);
      }
    }
    for (int i = 0; i + 1 < tmp.size(); i += 2) {
      ans.push_back({tmp[i], x, tmp[i + 1]});
    }
    if (tmp.size() & 1) {
      if (fa != -1) ans.push_back({fa, x, tmp.back()});
      return 0;
    } else
      return 1;
  };
  for (int i = 0; i < n; i++) {
    if (dep[i] == -1) dfs(i, -1, 0);
  }
  cout << ans.size() << endl;
  for (auto [x, y, z] : ans)
    cout << x + 1 << ' ' << y + 1 << " " << z + 1 << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  while (T--) {
    solve();
  }
}
