#include <bits/stdc++.h>
using namespace std;
int n, m, tot = 0, deep, head[200001], d[200001], f[200001];
bool vis[200001], _is[200001];
struct data {
  int next, num;
} edge[400001];
struct ansdata {
  int x, y, z;
};
vector<ansdata> ans;
void add(int u, int v) {
  edge[++tot].next = head[u];
  edge[tot].num = v;
  head[u] = tot;
}
void dfs(int x, int fa) {
  vis[x] = 1;
  d[x] = ++deep;
  int nownum = -1;
  for (int i = head[x]; i != -1; i = edge[i].next) {
    int kx = edge[i].num;
    if (kx == fa) continue;
    if (!vis[kx]) {
      f[kx] = x;
      dfs(kx, x);
      continue;
    }
    if (d[kx] < d[x]) {
      if (nownum == -1)
        nownum = kx;
      else {
        ansdata nowans;
        nowans.x = nownum;
        nowans.y = x;
        nowans.z = kx;
        ans.push_back(nowans);
        nownum = -1;
      }
    }
  }
  for (int i = head[x]; i != -1; i = edge[i].next) {
    int kx = edge[i].num;
    if (f[kx] == x) {
      if (_is[kx]) continue;
      if (nownum == -1)
        nownum = kx;
      else {
        ansdata nowans;
        nowans.x = nownum;
        nowans.y = x;
        nowans.z = kx;
        ans.push_back(nowans);
        nownum = -1;
      }
    }
  }
  if (f[x] == 0) return;
  _is[x] = 0;
  if (nownum != -1) {
    ansdata nowans;
    nowans.x = nownum;
    nowans.y = x;
    nowans.z = f[x];
    ans.push_back(nowans);
    _is[x] = 1;
  }
  --deep;
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      deep = 0;
      dfs(i, -1);
    }
  int nx = ans.size();
  printf("%d\n", nx);
  for (int i = 0; i < nx; i++)
    printf("%d %d %d\n", ans[i].x, ans[i].y, ans[i].z);
  return 0;
}
