#include <bits/stdc++.h>
int xx[200000], yy[200000], zz[200000], k;
struct L {
  struct L *next;
  int j;
} aa[1 + 200000];
int dd[1 + 200000];
void link(int i, int j) {
  static struct L l91[200000 * 2], *l = l91;
  l->j = j;
  l->next = aa[i].next;
  aa[i].next = l++;
}
int dfs(int p, int i, int d) {
  struct L *l;
  int q;
  if (dd[i]) return dd[i] < d;
  dd[i] = d;
  q = 0;
  for (l = aa[i].next; l; l = l->next) {
    int j = l->j;
    if (j != p && dfs(i, j, d + 1)) {
      if (q == 0)
        q = j;
      else {
        xx[k] = q, yy[k] = i, zz[k] = j, k++;
        q = 0;
      }
    }
  }
  if (p != 0 && q != 0) {
    xx[k] = q, yy[k] = i, zz[k] = p, k++;
    return 0;
  }
  return q == 0;
}
int main() {
  int n, m, h, i, j;
  scanf("%d%d", &n, &m);
  for (h = 0; h < m; h++) {
    scanf("%d%d", &i, &j);
    link(i, j);
    link(j, i);
  }
  for (i = 1; i <= n; i++) dfs(0, i, 1);
  printf("%d\n", k);
  while (k--) printf("%d %d %d\n", xx[k], yy[k], zz[k]);
  return 0;
}
