#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
set<int> adj[200010];
set<int> adjs[200010];
int lvl[200010];
vector<tuple<int, int, int> > ans;
void dfs(int u, int p) {
  for (auto v : adjs[u]) {
    if (v == p or lvl[v]) continue;
    lvl[v] = lvl[u] + 1;
    dfs(v, u);
  }
  if (p != -1) adj[u].erase(p);
  for (auto v = adj[u].begin(); v != adj[u].end();) {
    auto w = next(v);
    if (w != adj[u].end()) {
      ans.push_back({*v, u, *w});
      adj[*v].erase(u);
      adj[*w].erase(u);
      v = next(w);
    } else if (p != -1) {
      ans.push_back({*v, u, p});
      adj[p].erase(u);
      adj[*v].erase(u);
      break;
    } else
      break;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].insert(b);
    adj[b].insert(a);
    adjs[a].insert(b);
    adjs[b].insert(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!lvl[i]) {
      lvl[i] = 1;
      dfs(i, -1);
    }
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << get<0>(x) << ' ' << get<1>(x) << ' ' << get<2>(x) << endl;
  }
}
