#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int ans[N][3], len = 0;
void addans(int u, int v, int w) {
  ans[len][0] = u + 1;
  ans[len][1] = v + 1;
  ans[len][2] = w + 1;
  len++;
}
void showans() {
  cout << len << '\n';
  for (int i = 0; i < len; i++) {
    cout << ans[i][0] << ' ';
    cout << ans[i][1] << ' ';
    cout << ans[i][2] << '\n';
  }
}
list<int> adj[N];
int vis[N], dep[N];
int dfs(int u, int p, int d = 0) {
  if (vis[u]) return 0;
  vis[u] = 1;
  dep[u] = d;
  int rem = adj[u].size();
  list<int> nused;
  for (int v : adj[u]) {
    if (dep[v] >= 0 && dep[v] < dep[u]) continue;
    if (!dfs(v, u, d + 1)) {
      nused.push_back(v);
      rem--;
    }
  }
  while (nused.size() >= 2) {
    int x = nused.front();
    nused.pop_front();
    int y = nused.front();
    nused.pop_front();
    addans(x, u, y);
  }
  if (!nused.empty() && p != -1) {
    addans(nused.front(), u, p);
    return 1;
  }
  return 0;
}
int main() {
  memset(dep, -1, sizeof(dep));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u - 1].push_back(v - 1);
    adj[v - 1].push_back(u - 1);
  }
  for (int u = 0; u < n; u++) {
    if (!vis[u]) dfs(u, -1);
  }
  showans();
  return 0;
}
