#include <bits/stdc++.h>
using namespace std;
const int Max = 1e6 + 10;
int X[Max], Y[Max];
vector<int> N[Max];
bool seen[Max];
bool used[Max];
vector<pair<int, int>> res;
void DFS(int v, int e = 0) {
  seen[v] = 1;
  int E = 0;
  for (int i : N[v]) {
    int u;
    if (i < 0)
      i = -i, u = X[i];
    else
      u = Y[i];
    if (seen[u]) {
      if (!used[i] && i != e) {
        if (E)
          used[i] = 1, res.push_back(make_pair(E, i)), E = 0;
        else
          E = i, used[i] = 1;
      }
    } else {
      DFS(u, i);
      if (!used[i]) {
        if (E)
          used[i] = 1, res.push_back(make_pair(E, i)), E = 0;
        else
          E = i, used[i] = 1;
      }
    }
  }
  if (E && e) used[E] = used[e] = 1, res.push_back(make_pair(E, e));
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> X[i] >> Y[i];
    N[X[i]].push_back(i);
    N[Y[i]].push_back(-i);
  }
  for (int i = 1; i <= n; i++)
    if (!seen[i]) DFS(i);
  cout << '\n';
  cout << res.size() << '\n';
  for (pair<int, int> x : res) {
    int x1 = X[x.first], y1 = Y[x.first], x2 = X[x.second], y2 = Y[x.second];
    if (x1 == x2)
      cout << y1 << ' ' << x1 << ' ' << y2 << '\n';
    else if (x1 == y2)
      cout << y1 << ' ' << x1 << ' ' << x2 << '\n';
    else if (y1 == x2)
      cout << x1 << ' ' << y1 << ' ' << y2 << '\n';
    else if (y1 == y2)
      cout << x1 << ' ' << y1 << ' ' << x2 << '\n';
  }
}
