#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N];
vector<vector<int>> v;
int tin[N];
int timer = 1;
bool dfs(int node, int anc = -1) {
  tin[node] = timer++;
  int last = -1;
  for (int to : g[node]) {
    if (tin[to] && tin[to] < tin[node]) continue;
    if (tin[to] || dfs(to, node)) {
      if (last == -1) {
        last = to;
      } else {
        v.push_back({last, node, to});
        last = -1;
      }
    }
  }
  if (last != -1 && anc != -1) {
    v.push_back({last, node, anc});
    return false;
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!tin[i]) {
      dfs(i);
    }
  }
  printf("%d\n", v.size());
  for (auto &a : v) {
    for (int i : a) printf("%d ", i);
    printf("\n");
  }
  return 0;
}
