#include <bits/stdc++.h>
using namespace std;
int n, m;
int vis[400005], tag[400005];
int head[400005], ne[800005], to[800005], mark[800005], cnte = 1;
int ans[400005 << 2], tot;
inline void add(int x, int y) {
  ne[++cnte] = head[x], head[x] = cnte, to[cnte] = y;
  ne[++cnte] = head[y], head[y] = cnte, to[cnte] = x;
}
void add_ans(int x, int y, int z) {
  ans[++tot] = x, ans[++tot] = y, ans[++tot] = z;
}
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int i = head[x]; i; i = ne[i]) {
    if (mark[i] || mark[i ^ 1]) continue;
    mark[i] = 1, dfs(to[i]);
    if (tag[to[i]]) {
      add_ans(tag[to[i]], to[i], x);
      tag[to[i]] = 0;
    } else if (tag[x]) {
      add_ans(tag[x], x, to[i]);
      tag[x] = 0;
    } else
      tag[x] = to[i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; ++i) cin >> x >> y, add(x, y);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i);
  cout << tot / 3 << endl;
  for (int i = 1; i <= tot; ++i) cout << ans[i] << " \n"[i % 3 == 0];
  return 0;
}
