#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
const int mod = 1e9 + 7;
vector<int> g[maxn];
int mark[maxn], took[maxn];
vector<pair<pair<int, int>, int> > ans;
void solve(int u, int par = -1) {
  vector<int> t;
  mark[u] = 1;
  for (auto v : g[u]) {
    if (v == par || mark[v] == 2) continue;
    if (mark[v] == 1) {
      t.push_back(v);
      continue;
    }
    solve(v, u);
    if (~took[v])
      ans.push_back({{u, v}, took[v]});
    else
      t.push_back(v);
  }
  for (int i = 0; i < (int)t.size() - 1; i += 2)
    ans.push_back({{t[i], u}, t[i + 1]});
  if ((int)t.size() % 2) took[u] = t.back();
  mark[u] = 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) took[i] = -1;
  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);
  }
  for (int i = 0; i < n; ++i)
    if (!mark[i]) solve(i);
  cout << (int)ans.size() << '\n';
  for (auto e : ans)
    cout << e.first.first + 1 << ' ' << e.first.second + 1 << ' '
         << e.second + 1 << '\n';
  return 0;
}
