#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 7;
long long n, m, a[maxn], par[maxn], delp[maxn], cnt;
long long num[maxn], delpar[maxn];
vector<long long> cac[maxn];
vector<long long> vt[maxn];
long long ans1[maxn], ans2[maxn], ans3[maxn], cnt2;
void DFS(long long u, long long p) {
  par[u] = p;
  num[u] = ++cnt2;
  for (auto v : vt[u]) {
    if (v == p) continue;
    if (num[v] == 0) {
      DFS(v, u);
      if (!delpar[v]) {
        cac[u].push_back(v);
      }
    } else if (num[v] < num[u]) {
      cac[v].push_back(u);
    }
  }
  for (long long i = 0; i + 1 < cac[u].size(); i += 2) {
    ans1[++cnt] = cac[u][i];
    ans2[cnt] = u;
    ans3[cnt] = cac[u][i + 1];
  }
  if (cac[u].size() & 1) {
    if (par[u] != u) {
      ans1[++cnt] = cac[u].back();
      ans2[cnt] = u;
      ans3[cnt] = par[u];
      delpar[u] = 1;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    vt[u].push_back(v);
    vt[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) {
    if (par[i] == 0) {
      par[i] = i;
      DFS(i, i);
    }
  }
  cout << cnt << '\n';
  for (long long i = 1; i <= cnt; i++) {
    cout << ans1[i] << ' ' << ans2[i] << ' ' << ans3[i] << "\n";
  }
}
