#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
vector<vector<long long> > ed;
vector<long long> visited;
vector<long long> depth;
vector<long long> res1;
vector<long long> res2;
vector<long long> res3;
bool dfs(long long a, long long from, long long d) {
  depth[a] = d;
  visited[a] = 1;
  long long v1 = -1;
  bool f;
  for (long long i = 0; i < ed[a].size(); i++) {
    f = true;
    if (visited[ed[a][i]] == 0) {
      f = dfs(ed[a][i], a, d + 1);
    }
    if (ed[a][i] != from && depth[a] <= depth[ed[a][i]]) {
      if (f) {
        if (v1 == -1) {
          v1 = ed[a][i];
        } else {
          res1.push_back(v1);
          res2.push_back(a);
          res3.push_back(ed[a][i]);
          v1 = -1;
        }
      }
    }
  }
  if (v1 != -1) {
    if (from != -1) {
      res1.push_back(v1);
      res2.push_back(a);
      res3.push_back(from);
      return false;
    }
  }
  return true;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  ed.resize(N);
  depth.resize(N);
  visited.resize(N, 0);
  vector<long long> A(N);
  long long res = 0;
  long long a, b;
  for (long long i = 0; i < M; i++) {
    cin >> a >> b;
    a--;
    b--;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  for (long long i = 0; i < N; i++) {
    if (visited[i] == 0) {
      dfs(i, -1, 0);
    }
  }
  cout << res1.size() << endl;
  for (long long i = 0; i < res1.size(); i++) {
    cout << res1[i] + 1 << " " << res2[i] + 1 << " " << res3[i] + 1 << endl;
  }
}
