#include <bits/stdc++.h>
using namespace std;
vector<set<int>> g;
vector<array<int, 3>> res;
vector<int> was;
void del(int a, int b) {
  g[a].erase(b);
  g[b].erase(a);
}
void push(int a, int b, int c) {
  res.push_back({a, b, c});
  del(a, b);
  del(b, c);
}
bool dfs(int v, int p) {
  if (was[v]) return 0;
  was[v] = 1;
  vector<int> bad, all;
  for (int nv : g[v]) {
    all.push_back(nv);
  }
  for (int nv : all) {
    if (!g[v].count(nv) || nv == p) continue;
    if (!was[nv]) {
      if (dfs(nv, v)) {
        bad.push_back(nv);
      }
    } else {
      bad.push_back(nv);
    }
  }
  while (bad.size() >= 2) {
    int a = bad.back();
    bad.pop_back();
    int b = bad.back();
    bad.pop_back();
    push(a, v, b);
  }
  if (bad.empty()) return true;
  if (p != -1) push(bad[0], v, p);
  return false;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  g.resize(n);
  was.assign(n, 0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].insert(b);
    g[b].insert(a);
  }
  for (int i = 0; i < n; ++i)
    if (!was[i] && !g[i].empty()) {
      dfs(i, -1);
    }
  printf("%d\n", (int)res.size());
  for (auto v : res) {
    printf("%d %d %d\n", v[0] + 1, v[1] + 1, v[2] + 1);
  }
  return 0;
}
