#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
const int N = 200005;
int n, ticks, visited[N], tin[N];
vector<int> adj[N];
vector<pair<pair<int, int>, int> > ans;
int dfs(int v, int last) {
  visited[v] = true;
  tin[v] = ++ticks;
  vector<int> avail;
  for (auto vv : adj[v]) {
    if (vv == last) continue;
    if (visited[vv] && tin[vv] < tin[v])
      avail.push_back(vv);
    else if (!visited[vv] && dfs(vv, v))
      avail.push_back(vv);
  }
  while ((int)avail.size() > 1) {
    int a = avail.back();
    avail.pop_back();
    int b = avail.back();
    avail.pop_back();
    ans.push_back({{a, v}, b});
  }
  if (!avail.empty() && last != -1) {
    ans.push_back({{last, v}, avail.back()});
    return 0;
  }
  return 1;
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!visited[i]) dfs(i, -1);
  printf("%d\n", (int)ans.size());
  for (auto it : ans)
    printf("%d %d %d\n", it.first.first, it.first.second, it.second);
  return 0;
}
