#include <bits/stdc++.h>
const int N = 200010, M = 400010;
int n, m, e = 1, lnk[N], nxt[M], to[M], cnt, ans, qwq;
bool b[N], g[M];
inline void add(int x, int y) {
  to[++e] = y;
  nxt[e] = lnk[x];
  lnk[x] = e;
}
void pre(int x) {
  b[x] = true;
  for (int i = lnk[x]; i; i = nxt[i]) {
    ++cnt;
    if (!b[to[i]]) pre(to[i]);
  }
}
void dfs(int x, int fa) {
  int i, y, t = -1;
  std::vector<int> v;
  b[x] = true;
  for (i = lnk[x]; i; i = nxt[i]) {
    if (!b[y = to[i]]) dfs(y, x);
    if (!g[i] && y != fa) v.push_back(i);
    if (y == fa) t = i;
  }
  if (t > 0 && (v.size() & 1)) v.push_back(t);
  for (i = 1; i < v.size(); i += 2) {
    printf("%d %d %d\n", to[v[i - 1]], x, to[v[i]]);
    ++qwq;
    g[v[i - 1]] = g[v[i - 1] ^ 1] = g[v[i]] = g[v[i] ^ 1] = true;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int x, y, i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!b[i]) cnt = 0, pre(i), ans += cnt >> 2;
  memset(b, 0, sizeof b);
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i)
    if (!b[i]) dfs(i, 0);
}
