#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> neigh;
  int par = 0;
  bool visited = 0;
  vector<int> active;
  int depth;
};
vector<pair<int, pair<int, int>>> ans;
int n, m, x, y;
node A[200005];
bool dfs(int nd, int from) {
  if (A[nd].visited) return A[nd].depth < A[from].depth;
  A[nd].par = from;
  A[nd].depth = A[from].depth + 1;
  A[nd].visited = 1;
  for (int x : A[nd].neigh)
    if (x != A[nd].par) {
      if (dfs(x, nd)) A[nd].active.push_back(x);
      if (A[nd].active.size() == 2) {
        ans.push_back({A[nd].active[0], {nd, A[nd].active[1]}});
        A[nd].active.clear();
      }
    }
  if (A[nd].active.size() && A[nd].par != 0) {
    ans.push_back({A[nd].active[0], {nd, A[nd].par}});
    A[nd].active.clear();
    return 0;
  }
  return 1;
}
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    A[x].neigh.push_back(y);
    A[y].neigh.push_back(x);
  }
  for (int i = 1; i <= n; i++) dfs(i, 0);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second.first << " "
         << ans[i].second.second << endl;
  }
}
