#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int MAXM = 1e5 + 5;
const int mod = 1e9 + 7;
int n, m;
int vis[MAXN], num[MAXN], dep[MAXN];
vector<int> edge[MAXN], ans[MAXN];
void link(int a, int b) { edge[a].push_back(b); }
void initialize() {
  memset(num, 0, sizeof(num));
  memset(dep, 0, sizeof(dep));
}
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  vis[u] = 1;
  for (auto v : edge[u]) {
    if (v == fa) continue;
    if (vis[v] == 0) {
      dfs(v, u);
    } else {
      if (dep[v] > dep[u]) {
        num[u] ^= 1;
        ans[u].push_back(v);
      }
    }
  }
  if (fa == 0) return;
  if (num[u] == 0) {
    num[fa] ^= 1;
    ans[fa].push_back(u);
  } else {
    num[u] ^= 1;
    ans[u].push_back(fa);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  initialize();
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    link(a, b);
    link(b, a);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) dfs(i, 0);
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) sum += ans[i].size() / 2;
  printf("%d\n", sum);
  for (int i = 1; i <= n; i++) {
    int len = ans[i].size();
    for (int j = 0; j + 1 < len; j += 2) {
      printf("%d %d %d\n", ans[i][j], i, ans[i][j + 1]);
    }
  }
  return 0;
}
