#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 101110;
struct Ti {
  int x, y, z;
  Ti(int X, int Y, int Z) {
    x = X;
    y = Y;
    z = Z;
  }
};
int n, m, cnt = 0;
int num[N], P[N];
vector<int> G[N];
vector<Ti> ans;
void visit(int u, int par) {
  num[u] = ++cnt;
  int cur = 0;
  for (int i = 0, v; i < G[u].size(); i++) {
    v = G[u][i];
    if (num[v]) {
      if (v != par && num[v] < num[u]) {
        if (cur) {
          ans.push_back(Ti(cur, u, v));
          cur = 0;
        } else
          cur = v;
      }
    } else {
      visit(v, u);
      if (P[v])
        ans.push_back(Ti(u, v, P[v]));
      else {
        if (cur) {
          ans.push_back(Ti(cur, u, v));
          cur = 0;
        } else
          cur = v;
      }
    }
  }
  P[u] = cur;
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!num[i]) visit(i, i);
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d %d\n", ans[i].x, ans[i].y, ans[i].z);
}
