#include <bits/stdc++.h>
const int kN = 200000 + 5;
int n, m;
std::vector<int> edges[kN];
std::vector<std::tuple<int, int, int>> result;
int depth[kN];
int dfs(int u, int fa) {
  depth[u] = depth[fa] + 1;
  int unmatched = 0;
  for (int v : edges[u]) {
    if (depth[v] == 0) {
      int w = dfs(v, u);
      if (w) {
        result.emplace_back(u, v, w);
      } else if (unmatched) {
        result.emplace_back(unmatched, u, v);
        unmatched = 0;
      } else {
        unmatched = v;
      }
    } else if (depth[v] > depth[u]) {
      if (unmatched) {
        result.emplace_back(unmatched, u, v);
        unmatched = 0;
      } else {
        unmatched = v;
      }
    }
  }
  return unmatched;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  for (int i = 1; i <= n; ++i)
    if (depth[i] == 0) dfs(i, 0);
  printf("%d\n", result.size());
  for (const auto &w : result) {
    int a, b, c;
    std::tie(a, b, c) = w;
    printf("%d %d %d\n", a, b, c);
  }
}
