#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10, inf = 4e18, mod = 1e9 + 7;
const long double pi = 3.14159265359, eps = 1e-9;
long long n, m;
vector<long long> g[maxn], jj[3];
long long mk[maxn];
bool dfs(long long v, long long p = -1, long long dep = 1) {
  mk[v] = dep;
  vector<long long> be, sn;
  for (auto u : g[v]) {
    if (mk[u] != 0 && mk[u] < mk[v]) {
      if (u != p) be.push_back(u);
      continue;
    }
    if (mk[u] == 0 && dfs(u, v, dep + 1)) sn.push_back(u);
  }
  while (be.size() > 1) {
    jj[0].push_back(be.back());
    be.pop_back();
    jj[1].push_back(v);
    jj[2].push_back(be.back());
    be.pop_back();
  }
  while (sn.size() > 1) {
    jj[0].push_back(sn.back());
    sn.pop_back();
    jj[1].push_back(v);
    jj[2].push_back(sn.back());
    sn.pop_back();
  }
  long long add = 0;
  if (be.size()) {
    if (sn.size()) {
      jj[0].push_back(sn.back());
      sn.pop_back();
      jj[1].push_back(v);
      jj[2].push_back(be.back());
      be.pop_back();
      return 1;
    }
    add = be.back();
  } else if (sn.size()) {
    add = sn.back();
  }
  if (!add) return 1;
  if (p != -1) {
    jj[0].push_back(add);
    jj[1].push_back(v);
    jj[2].push_back(p);
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  long long v, u;
  while (m--) {
    cin >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    if (!mk[i]) dfs(i);
  }
  cout << jj[0].size() << endl;
  for (int i = 0; i < jj[0].size(); i++) {
    cout << jj[0][i] << ' ' << jj[1][i] << ' ' << jj[2][i] << endl;
  }
  return 0;
}
