#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
vector<int> graf[N];
int vst[N], Taken[N], Depth[N];
void dfs(int a, vector<int> &tab) {
  ("dfs %d (%d)\n", a, Depth[a]);
  tab.push_back(a);
  vst[a]++;
  for (int s : graf[a])
    if (vst[s] == 0) {
      Depth[s] = Depth[a] + 1;
      dfs(s, tab);
    }
}
void solve(int a, int b) {
  vector<int> V;
  for (int s : graf[a])
    if (Depth[s] > Depth[b]) {
      if (Depth[s] == Depth[a] + 1) {
        solve(s, a);
        if (Taken[s] == 0) V.push_back(s);
      } else
        V.push_back(s);
    }
  ("solve for %d: ", a);
  for (int v : V) ("%d ", v);
  ("\n");
  if ((int)V.size() % 2 == 1 && a != b) {
    Taken[a] = 1;
    V.push_back(b);
  }
  for (int i = 0; i < (int)V.size() / 2; i++)
    printf("%d %d %d\n", V[i * 2], a, V[i * 2 + 1]);
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    graf[a].push_back(b);
    graf[b].push_back(a);
  }
  int w = 0;
  for (int i = 1; i < n + 1; i++)
    if (vst[i] == 0) {
      vector<int> tab;
      dfs(i, tab);
      int s = 0;
      for (int v : tab) s += (int)graf[v].size();
      w += s / 4;
    }
  printf("%d\n", w);
  for (int i = 1; i < n + 1; i++)
    if (Depth[i] == 0) {
      solve(i, i);
    }
}
