#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n, m;
int head[N], cnt;
struct edge {
  int to, next, id;
} e[N << 1];
int u[N], v[N];
void adde(int a, int b, int c) {
  e[++cnt].to = b;
  e[cnt].next = head[a];
  head[a] = cnt;
  e[cnt].id = c;
}
int id[N];
int fa[N];
int gf(int k) { return fa[k] == k ? k : fa[k] = gf(fa[k]); }
int dep[N];
int in[N], pos[N], num[N];
int gi() {
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') f = f * 10 + ch - 48, ch = getchar();
  return f;
}
void dfs(int x, int f) {
  dep[x] = dep[f] + 1;
  if (in[x] & 1) pos[++cnt] = x;
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    dfs(v, x);
  }
}
void getnum(int k, int f) {
  for (int i = head[k]; i; i = e[i].next) {
    int to = e[i].to;
    if (to == f) continue;
    getnum(to, k);
    num[k] ^= num[to];
    if (num[to]) swap(u[e[i].id], v[e[i].id]);
  }
}
void work(int k) {
  cnt = 0;
  dfs(k, 0);
  for (int i = 1; i < cnt; i += 2) num[pos[i]] ^= 1, num[pos[i + 1]] ^= 1;
  getnum(k, 0);
}
int pre[N], ans;
int outx[N], outy[N], outz[N];
int main() {
  n = gi();
  m = gi();
  for (int i = 1; i <= m; i++) u[i] = gi(), v[i] = gi(), in[u[i]]++;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++)
    if (gf(u[i]) != gf(v[i]))
      adde(u[i], v[i], i), adde(v[i], u[i], i), fa[gf(u[i])] = gf(v[i]);
  for (int i = 1; i <= n; i++)
    if (gf(i) == i) work(i);
  for (int i = 1; i <= m; i++)
    if (pre[u[i]])
      outx[++ans] = pre[u[i]], outy[ans] = u[i], outz[ans] = v[i],
      pre[u[i]] = 0;
    else
      pre[u[i]] = v[i];
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++)
    printf("%d %d %d\n", outx[i], outy[i], outz[i]);
  return 0;
}
