#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> adj[200005];
bool vis[200005];
int depth[200005];
bool used_parent[200005];
vector<vector<int>> paths;
void dfs(int u, int p) {
  depth[u] = depth[p] + 1;
  vis[u] = 1;
  vector<int> nodes;
  for (auto v : adj[u]) {
    if (v == p) continue;
    if (vis[v]) {
      if (depth[v] < depth[u]) nodes.emplace_back(v);
      continue;
    }
    dfs(v, u);
    if (!used_parent[v]) nodes.emplace_back(v);
  }
  if ((int)nodes.size() & 1) {
    if (p) {
      used_parent[u] = 1;
      nodes.emplace_back(p);
    }
    for (int i = 0; i < (int)nodes.size() - 1; i += 2) {
      vector<int> path;
      path.emplace_back(nodes[i]);
      path.emplace_back(u);
      path.emplace_back(nodes[i + 1]);
      paths.emplace_back(path);
    }
  } else {
    for (int i = 0; i < (int)nodes.size() - 1; i += 2) {
      vector<int> path;
      path.emplace_back(nodes[i]);
      path.emplace_back(u);
      path.emplace_back(nodes[i + 1]);
      paths.emplace_back(path);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  for (int u = 1; u <= n; u++) {
    if (!vis[u]) dfs(u, 0);
  }
  cout << (int)paths.size() << "\n";
  for (auto path : paths) {
    for (auto node : path) cout << node << " ";
    cout << "\n";
  }
}
