#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> E[300000];
int vis[300000];
vector<vector<int> > V;
void out(int a, int b, int c) { V.push_back(vector<int>({a, b, c})); }
bool dfs(int x, int par = -1) {
  vis[x] = 1;
  int bal = -1;
  for (int y : E[x]) {
    if (vis[y] == 0) {
      if (dfs(y, x)) {
        if (bal == -1)
          bal = y;
        else {
          out(bal, x, y);
          bal = -1;
        }
      }
    } else if (vis[y] == 2) {
      if (bal == -1)
        bal = y;
      else {
        out(bal, x, y);
        bal = -1;
      }
    }
  }
  vis[x] = 2;
  if (bal != -1 && par != -1) {
    out(bal, x, par);
  } else
    return true;
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  for (int i = 0; i < n; ++i)
    if (vis[i] == 0) dfs(i);
  printf("%d\n", V.size());
  for (vector<int> v : V) {
    for (int x : v) printf("%d ", x + 1);
    puts("");
  }
  return 0;
}
