#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int> > adj;
struct Info {
  int a, b, c;
};
vector<Info> ans;
vector<int> tin;
int timer;
bool dfs(int u, int p) {
  tin[u] = timer++;
  vector<int> tmp;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (tin[v] != -1 && tin[v] < tin[u]) continue;
    if (tin[v] != -1 || dfs(v, u)) tmp.push_back(v);
  }
  for (int i = 0; i < (int)tmp.size() - 1; i += 2) {
    ans.push_back({tmp[i], u, tmp[i + 1]});
  }
  if (tmp.size() % 2) {
    if (p != -1) ans.push_back({tmp.back(), u, p});
    return false;
  } else
    return true;
}
int main() {
  scanf("%d %d", &N, &M);
  adj.resize(N);
  for (int i = 0; i < M; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  tin = vector<int>(N, -1);
  timer = 0;
  for (int i = 0; i < N; i++)
    if (tin[i] == -1) dfs(i, -1);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d %d\n", ans[i].a + 1, ans[i].b + 1, ans[i].c + 1);
  }
}
