#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
bool vis[N];
unordered_set<int> G[N];
struct tp {
  int x, y, z;
};
vector<tp> ans;
int solve(int x) {
  if (vis[x]) return 0;
  vis[x] = 1;
  vector<int> adj;
  for (int u : G[x]) {
    adj.push_back(u);
    G[u].erase(x);
  }
  vector<int> remain;
  for (int u : adj) {
    int res = solve(u);
    if (res) {
      ans.push_back((tp){x, u, res});
    } else {
      remain.push_back(u);
    }
  }
  while ((int)remain.size() >= 2) {
    int u = remain.back();
    remain.pop_back();
    int v = remain.back();
    remain.pop_back();
    ans.push_back((tp){u, x, v});
  }
  if (remain.empty()) return 0;
  return remain[0];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].insert(v);
    G[v].insert(u);
  }
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    solve(i);
  }
  printf("%d\n", (int)ans.size());
  for (auto a : ans) printf("%d %d %d\n", a.x, a.y, a.z);
}
