#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9, MOD = INF + 7;
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long power(long long a, long long b) {
  return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1));
}
long long mod(long long a) { return (a % MOD + MOD) % MOD; }
const long long N = 1e6 + 20;
vector<long long> g[N];
long long mark[N];
vector<pair<long long, pair<long long, long long> > > ans;
bool dfs(long long v, long long par = 0) {
  mark[v] = 1;
  long long tmp = 0;
  for (long long u : g[v]) {
    if (u == par || mark[u] == 2) continue;
    if (mark[u] == 0 && dfs(u, v)) continue;
    if (tmp == 0)
      tmp = u;
    else
      ans.push_back(make_pair(v, make_pair(u, tmp))), tmp = 0;
  }
  mark[v] = 2;
  if (tmp != 0 && par != 0) ans.push_back(make_pair(v, make_pair(tmp, par)));
  return tmp;
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++)
    if (mark[i] == 0) dfs(i);
  cout << ans.size() << "\n";
  for (auto p : ans)
    cout << p.second.first << " " << p.first << " " << p.second.second << "\n";
  return 0;
}
