#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > G;
vector<int> visited;
vector<vector<int> > carry;
vector<vector<int> > ans;
void dfs(int u, int p) {
  visited[u] = 1;
  vector<int> edges;
  for (int v : G[u]) {
    if (visited[v] == 0)
      dfs(v, u);
    else if (visited[v] == 1) {
      if (v != p) edges.push_back(v);
    }
  }
  for (int x : carry[u]) edges.push_back(x);
  int x = -1;
  while (!edges.empty()) {
    x = edges.back();
    edges.pop_back();
    if (!edges.empty()) {
      int z = edges.back();
      edges.pop_back();
      ans.push_back({x, u, z});
      x = -1;
    }
  }
  if (x != -1 && p != -1) {
    ans.push_back({x, u, p});
  } else if (x == -1 && p != -1) {
    carry[p].push_back(u);
  }
  visited[u] = 2;
}
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  G.resize(n);
  visited.resize(n);
  carry.resize(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);
  }
  for (int i = 0; i < n; i++)
    if (!visited[i]) dfs(i, -1);
  cout << ans.size() << endl;
  for (vector<int> A : ans) {
    for (int x : A) cout << x + 1 << " ";
    cout << endl;
  }
  return 0;
}
