#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 15;
vector<int> adj[N];
int depth[N];
struct node {
  int s, m, t;
  node() {}
  node(int s, int m, int t) : s(s), m(m), t(t) {}
};
vector<node> ret;
int dfs(int root, int par) {
  depth[root] = depth[par] + 1;
  int u, i, v;
  vector<int> remain;
  for (i = 0; i < adj[root].size(); ++i) {
    u = adj[root][i];
    if (u == par) continue;
    if (depth[u] == 0) {
      v = dfs(u, root);
      if (v == u) {
        remain.push_back(v);
      } else {
        ret.push_back(node(root, u, v));
      }
    } else if (depth[u] < depth[root]) {
      remain.push_back(u);
    }
  }
  for (i = 0; i < (int)remain.size() - 1; i += 2) {
    u = remain[i], v = remain[i + 1];
    ret.push_back(node(u, root, v));
  }
  if (remain.size() & 1) {
    return remain.back();
  }
  return root;
}
int main() {
  int m, n, i, a, b;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (i = 1; i <= n; ++i) {
    if (depth[i] == 0) dfs(i, 0);
  }
  cout << (int)ret.size() << endl;
  for (i = 0; i < ret.size(); ++i)
    printf("%d %d %d\n", ret[i].s, ret[i].m, ret[i].t);
}
