#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 20;
int vist[N];
vector<int> adj[N];
vector<array<int, 3>> res;
int dfs(int u, int p = -1) {
  vector<int> vec;
  vist[u] = 1;
  for (int v : adj[u])
    if (v != p) {
      if (!vist[v]) {
        int x = dfs(v, u);
        if (x == -1) vec.push_back(v);
      } else if (vist[v] == 2) {
        vec.push_back(v);
      }
    }
  int r = -1;
  while (int(vec.size()) > 1) {
    int x = vec.back();
    vec.pop_back();
    int z = vec.back();
    vec.pop_back();
    res.push_back({x, u, z});
  }
  if (p >= 0 && int(vec.size()) == 1) {
    int x = vec.back();
    vec.pop_back();
    res.push_back({x, u, p});
    r = 1;
  }
  vist[u] = 2;
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    if (!vist[i]) {
      dfs(i);
    }
  }
  cout << int(res.size()) << '\n';
  for (auto [x, y, z] : res) {
    cout << x + 1 << " " << y + 1 << " " << z + 1 << '\n';
  }
  return 0;
}
