#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300100;
int n, m, a, b, h[MAXN];
vector<int> g[MAXN];
vector<pair<pair<int, int>, int> > ans;
bool used[MAXN], vis[MAXN];
void dfs(int v, int pr) {
  vector<int> q;
  vis[v] = true;
  for (auto i : g[v]) {
    if (!vis[i]) {
      h[i] = h[v] + 1;
      dfs(i, v);
      if (!used[i]) {
        q.push_back(i);
      }
    } else if (h[i] > h[v]) {
      q.push_back(i);
    }
  }
  for (int i = 0; i + 1 < q.size(); i += 2) {
    ans.push_back({{q[i], v}, q[i + 1]});
  }
  if (q.size() % 2 && pr != -1) {
    ans.push_back({{q[q.size() - 1], v}, pr});
    used[v] = true;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i, -1);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first.first + 1 << " " << ans[i].first.second + 1 << " "
         << ans[i].second + 1 << endl;
  }
  return 0;
}
