#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[200007];
vector<pair<pair<int, int>, int> > ans;
bool was[200007];
int h[200007];
int dfs(int v, int hh) {
  if (was[v]) return -1;
  h[v] = hh;
  was[v] = 1;
  vector<int> tmp;
  for (int to : g[v])
    if (h[v] < h[to]) {
      auto ww = dfs(to, hh + 1);
      if (ww == -1)
        tmp.push_back(to);
      else
        ans.push_back(make_pair(make_pair(ww, to), v));
    }
  while (tmp.size() >= 2) {
    ans.push_back(
        make_pair(make_pair(tmp.back(), v), tmp[(int)tmp.size() - 2]));
    tmp.pop_back();
    tmp.pop_back();
  }
  if (tmp.size() == 1) return tmp[0];
  return -1;
}
int main() {
  srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N' + time(NULL));
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) h[i] = n + 7;
  for (int i = 0; i < n; i++)
    if (!was[i]) dfs(i, 0);
  cout << ans.size() << "\n";
  for (auto c : ans)
    cout << c.first.first + 1 << ' ' << c.first.second + 1 << ' '
         << c.second + 1 << "\n";
}
