#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> AdjList[200001];
vector<pair<int, pair<int, int> > > res;
bool visited[200001];
int h[200001];
void dfs(int u) {
  visited[u] = true;
  for (int i = 0; i < AdjList[u].size(); i++) {
    int v = AdjList[u][i];
    if (!visited[v]) {
      h[v] = h[u] + 1;
      dfs(v);
    }
  }
}
bool cal(int u, int p) {
  visited[u] = true;
  vector<int> tmp;
  for (int i = 0; i < AdjList[u].size(); i++) {
    int v = AdjList[u][i];
    if (!visited[v])
      if (cal(v, u)) tmp.push_back(v);
  }
  for (int i = 0; i < AdjList[u].size(); i++) {
    int v = AdjList[u][i];
    if (h[v] < h[u] && v != p) tmp.push_back(v);
  }
  bool ok = true;
  if ((int)tmp.size() % 2 == 0) {
    for (int i = 0; i < tmp.size(); i += 2)
      res.push_back(
          pair<int, pair<int, int> >(tmp[i], pair<int, int>(u, tmp[i + 1])));
  } else {
    ok = false;
    if (p != -1)
      res.push_back(pair<int, pair<int, int> >(p, pair<int, int>(u, tmp[0])));
    for (int i = 1; i < tmp.size(); i += 2)
      res.push_back(
          pair<int, pair<int, int> >(tmp[i], pair<int, int>(u, tmp[i + 1])));
  }
  return ok;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    AdjList[u].push_back(v);
    AdjList[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) visited[i] = false;
  for (int i = 1; i <= n; i++)
    if (!visited[i]) {
      h[i] = 1;
      dfs(i);
    }
  for (int i = 1; i <= n; i++) visited[i] = false;
  for (int i = 1; i <= n; i++)
    if (!visited[i]) cal(i, -1);
  cout << res.size() << '\n';
  for (auto& p : res)
    cout << p.first << ' ' << p.second.first << ' ' << p.second.second << '\n';
}
