#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
vector<int> a[maxn], bk[maxn];
int ni[maxn];
bool vis[maxn], prs[maxn];
vector<pair<int, pair<int, int>>> ans;
void dfs(int u, int p) {
  vis[u] = true;
  for (auto v : a[u]) {
    if (vis[v]) {
      if (v != p && ni[u] < ni[v]) bk[v].push_back(u);
      continue;
    }
    ni[v] = ni[u] + 1;
    dfs(v, u);
  }
  return;
}
void dojob(int u, int p) {
  vis[u] = true;
  vector<int> lis;
  for (auto v : a[u]) {
    if (vis[v]) continue;
    dojob(v, u);
    if (!prs[v]) lis.push_back(v);
  }
  int l = lis.size();
  for (int i = 1; i < l; i += 2) ans.push_back({lis[i - 1], {u, lis[i]}});
  if (bk[u].empty()) {
    if (p && l % 2) {
      prs[u] = true;
      ans.push_back({lis.back(), {u, p}});
    }
  } else {
    if (l % 2)
      ans.push_back({lis.back(), {u, bk[u].back()}});
    else {
      prs[u] = true;
      ans.push_back({p, {u, bk[u].back()}});
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int e1, e2;
    cin >> e1 >> e2;
    a[e1].push_back(e2);
    a[e2].push_back(e1);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    while (bk[i].size() > 1) {
      int a1 = bk[i].back();
      bk[i].pop_back();
      int b1 = bk[i].back();
      bk[i].pop_back();
      ans.push_back({a1, {i, b1}});
    }
  for (int i = 0; i < 200004; i++) vis[i] = false;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dojob(i, 0);
  cout << ans.size() << '\n';
  for (auto i : ans)
    cout << i.first << ' ' << i.second.first << ' ' << i.second.second << '\n';
  return 0;
}
