#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > g[200000];
bool e[200000];
bool used[200000];
vector<pair<pair<int, int>, int> > ans;
bool dfs(int v, int par) {
  int t = -1;
  used[v] = true;
  for (pair<int, int> to : g[v])
    if (!e[to.second]) {
      e[to.second] = true;
      if (!used[to.first]) {
        if (dfs(to.first, v)) {
          if (t == -1) {
            t = to.first;
          } else {
            ans.push_back(make_pair(make_pair(t, v), to.first));
            t = -1;
          }
        }
      } else {
        if (t == -1) {
          t = to.first;
        } else {
          ans.push_back(make_pair(make_pair(t, v), to.first));
          t = -1;
        }
      }
    }
  if (par != -1 && t != -1) {
    ans.push_back(make_pair(make_pair(t, v), par));
    return false;
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(m); ++i) {
    int from, to;
    scanf("%d%d", &from, &to), --from, --to;
    g[from].push_back(make_pair(to, i));
    g[to].push_back(make_pair(from, i));
  }
  for (int i = 0; i < (int)(n); ++i)
    if (!used[i]) {
      dfs(i, -1);
    }
  printf("%d\n", (int)ans.size());
  for (auto p : ans) {
    printf("%d %d %d\n", p.first.first + 1, p.first.second + 1, p.second + 1);
  }
  return 0;
}
