#include <bits/stdc++.h>
#pragma comment(linker, “/ STACK : 1024000000, 1024000000”)
using namespace std;
const int MAXM = 2e5 + 10;
const int MAXN = 2e5 + 10;
int n, m;
struct edge {
  int u, v;
  int next;
} e[MAXM * 2];
int vis[MAXM * 2];
int visv[MAXN];
int first[MAXN];
int deg[MAXN];
int fa[MAXN];
int idx, num;
struct node {
  int x, y, z;
} ans[MAXM];
void add(int u, int v) {
  e[idx].u = u;
  e[idx].v = v;
  e[idx].next = first[u];
  first[u] = idx++;
}
void init() {
  fill(first, first + n + 1, -1);
  fill(deg, deg + n + 1, 0);
  fill(visv, visv + n + 1, 0);
  memset(vis, 0, sizeof(vis));
  idx = 0;
  num = 0;
}
void dfs(int x, int p) {
  visv[x] = 1;
  fa[x] = p;
  for (int i = first[x]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (v == p) continue;
    if (visv[v]) continue;
    dfs(v, x);
  }
  if (deg[x] == 1 || deg[x] == 0) {
    return;
  }
  if (deg[x] % 2 == 1) {
    for (int i = first[x]; i != -1; i = e[i].next) {
      if (vis[i]) continue;
      int v = e[i].v;
      if (v == fa[x]) continue;
      vis[i] = vis[i ^ 1] = 1;
      deg[v]--;
      num++;
      if (num % 2 == 0) {
        ans[num / 2].y = x;
        ans[num / 2].z = v;
      } else {
        ans[(num + 1) / 2].x = v;
      }
    }
  } else {
    for (int i = first[x]; i != -1; i = e[i].next) {
      if (vis[i]) continue;
      vis[i] = vis[i ^ 1] = 1;
      int v = e[i].v;
      deg[v]--;
      num++;
      if (num % 2 == 0) {
        ans[num / 2].y = x;
        ans[num / 2].z = v;
      } else {
        ans[(num + 1) / 2].x = v;
      }
    }
  }
}
int f[MAXN];
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
int main() {
  scanf("%d%d", &n, &m);
  init();
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
    deg[u]++;
    deg[v]++;
    int fu = find(u);
    int fv = find(v);
    if (fu != fv) {
      f[fu] = fv;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (f[i] == i) {
      dfs(i, 0);
      if (num % 2 == 1) num--;
    }
  }
  printf("%d\n", num / 2);
  for (int i = 1; i <= num / 2; i++) {
    printf("%d %d %d\n", ans[i].x, ans[i].y, ans[i].z);
  };
  return 0;
};
