#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
struct Path {
  int x, y, z;
};
int n, m, dep[MAXN];
vector<int> a[MAXN];
vector<Path> Ans;
bool vst[MAXN];
inline const int getint() {
  int num = 0, bj = 1;
  char c = getchar();
  while (!isdigit(c)) bj = (c == '-' || bj == -1) ? -1 : 1, c = getchar();
  while (isdigit(c)) num = num * 10 + c - '0', c = getchar();
  return num * bj;
}
int Tarjan(int u, int fa, int depth) {
  vector<int> List;
  dep[u] = depth, vst[u] = 1;
  for (auto Next : a[u]) {
    if (Next == fa) continue;
    if (vst[Next]) {
      if (dep[Next] < dep[u]) List.push_back(Next);
      continue;
    } else {
      int Extra = Tarjan(Next, u, depth + 1);
      if (Extra != -1)
        Ans.push_back((Path){u, Next, Extra});
      else
        List.push_back(Next);
    }
  }
  for (unsigned register int i = 0; i + 1 < List.size(); i += 2)
    Ans.push_back((Path){List[i], u, List[i + 1]});
  if (List.size() & 1)
    return List.back();
  else
    return -1;
}
int main() {
  n = getint(), m = getint();
  for (register int i = 1; i <= m; i++) {
    int x = getint(), y = getint();
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (register int i = 1; i <= n; i++)
    if (!vst[i]) Tarjan(i, 0, 0);
  printf("%d\n", Ans.size());
  for (auto Edge : Ans) printf("%d %d %d\n", Edge.x, Edge.y, Edge.z);
  exit(0);
  return 0;
}
