#include <bits/stdc++.h>
using namespace std;
const int N = 400050;
vector<int> hh[N];
int n, m, cnt, a[N], b[N], c[N];
int head[N], to[N], nex[N], tot, vis[N];
void addedge(int u, int v) {
  tot++;
  to[tot] = v, nex[tot] = head[u], head[u] = tot;
  tot++;
  to[tot] = u, nex[tot] = head[v], head[v] = tot;
}
void dfs(int x, int fa) {
  vis[x] = 1;
  int i;
  for (i = head[x]; i; i = nex[i]) {
    if (to[i] != fa) {
      if (vis[to[i]])
        hh[to[i]].push_back(x);
      else {
        dfs(to[i], x);
        if (hh[to[i]].size() & 1)
          cnt++, a[cnt] = x, b[cnt] = to[i],
                 c[cnt] = hh[to[i]][hh[to[i]].size() - 1];
        else
          hh[x].push_back(to[i]);
      }
    }
  }
  for (i = 0; i + 1 < hh[x].size(); i += 2)
    cnt++, a[cnt] = hh[x][i], b[cnt] = x, c[cnt] = hh[x][i + 1];
}
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &j, &k);
    addedge(j, k);
  }
  for (i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  printf("%d\n", cnt);
  for (i = 1; i <= cnt; i++) printf("%d %d %d\n", a[i], b[i], c[i]);
  return 0;
}
