#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MN = 4e5 + 10;
int vis[MN], d[MN], odd[MN], xx[MN], yy[MN];
int cnt = 0, fst[MN], vb[MN], nxt[MN], vc[MN];
vector<int> ans[MN];
vector<int> e[MN];
void ins(int a, int b, int c) {
  ++cnt;
  nxt[cnt] = fst[a];
  fst[a] = cnt;
  vb[cnt] = b;
  vc[cnt] = c;
}
void insert(int a, int b, int c) {
  ins(a, b, c);
  ins(b, a, c);
}
void dfs(int x, int f = 0) {
  vis[x] = 1;
  d[x] = d[f] + 1;
  for (int e = fst[x], b = vb[e]; e; e = nxt[e], b = vb[e]) {
    if (b != f) {
      if (!vis[b]) {
        dfs(b, x);
        if (odd[b])
          odd[b] ^= 1, ans[b].push_back(vc[e]);
        else
          odd[x] ^= 1, ans[x].push_back(vc[e]);
      } else if (d[b] < d[x])
        odd[b] ^= 1, ans[b].push_back(vc[e]);
    }
  }
}
int main() {
  int n = read();
  int m = read();
  for (int i = 1; i <= m; i++) {
    xx[i] = read();
    yy[i] = read();
    insert(xx[i], yy[i], i);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  int o = 0;
  for (int i = 1; i <= n; i++) {
    vector<int> &v = ans[i];
    for (int g = 0; g + 1 < (int)v.size(); g += 2) o++;
  }
  printf("%d\n", o);
  for (int i = 1; i <= n; i++) {
    vector<int> &v = ans[i];
    for (int g = 0; g + 1 < (int)v.size(); g += 2) {
      int x = v[g], y = v[g + 1];
      int p = xx[x] ^ yy[x] ^ i;
      int q = xx[y] ^ yy[y] ^ i;
      printf("%d %d %d\n", p, i, q);
    }
  }
  return 0;
}
