#include <bits/stdc++.h>
const int maxn = 200005, maxm = 400005;
int n, m, e, anss;
int start[maxn], to[maxm], then[maxm], ans[maxn][3], visp[maxn], vise[maxm],
    rev[maxm], lst[maxn];
inline void add(int x, int y, int r) {
  then[++e] = start[x], start[x] = e, to[e] = y, rev[e] = r;
}
inline void getans(int a, int b, int c) {
  anss++, ans[anss][0] = a, ans[anss][1] = b, ans[anss][2] = c;
}
void dfs(int x) {
  visp[x] = 1;
  for (int i = start[x]; i; i = then[i])
    if (vise[i] == 0) {
      int y = to[i];
      vise[i] = vise[rev[i]] = 1;
      if (visp[y] == 0) dfs(y);
      if (lst[y])
        getans(lst[y], y, x), lst[y] = 0;
      else if (lst[x])
        getans(lst[x], x, y), lst[x] = 0;
      else
        lst[x] = y;
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y, e + 2), add(y, x, e);
  }
  for (int i = 1; i <= n; i++)
    if (visp[i] == 0) dfs(i);
  printf("%d\n", anss);
  for (int i = 1; i <= anss; i++)
    printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]);
  return 0;
}
