#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adj[200002];
int visited[200002];
vector<pair<int, int>> col[200002];
int cnt = 0;
bool solve(int v, int p) {
  visited[v] = ++cnt;
  int lastup = 0;
  for (int u : adj[v])
    if (u != p) {
      if ((visited[u] > 0 && visited[u] < visited[v]) ||
          (visited[u] == 0 && !solve(u, v))) {
        if (lastup > 0) {
          col[v].emplace_back(u, lastup);
          lastup = 0;
        } else {
          lastup = u;
        }
      }
    }
  if (lastup > 0) {
    if (p > 0) col[v].emplace_back(lastup, p);
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!visited[i]) solve(i, 0);
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += col[i].size();
  cout << ans << '\n';
  for (int i = 1; i <= n; i++)
    for (auto p : col[i])
      cout << p.first << ' ' << i << ' ' << p.second << '\n';
  return 0;
}
