#include <bits/stdc++.h>
using namespace std;
vector<int> g[200011];
bool vis[200011];
int h[200011];
vector<pair<pair<int, int>, int> > ans;
int dfs(int v, int p) {
  vis[v] = 1;
  if (p != -1) h[v] = h[p] + 1;
  vector<int> child;
  for (int i = 0; i < g[v].size(); i++) {
    if (!vis[g[v][i]]) {
      int rem = dfs(g[v][i], v);
      if (rem == -1) {
        child.push_back(g[v][i]);
      } else {
        ans.push_back(make_pair(make_pair(v, g[v][i]), rem));
      }
    } else if (h[g[v][i]] > h[v])
      child.push_back(g[v][i]);
  }
  for (int i = 1; i < child.size(); i += 2) {
    ans.push_back(make_pair(make_pair(child[i - 1], v), child[i]));
  }
  if (child.size() & 1) return child.back();
  return -1;
}
int main() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i, -1);
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first.first << " " << ans[i].first.second << " "
         << ans[i].second << "\n";
  }
}
