#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 10;
int n, m, cnt, vis[N];
vector<int> g[N];
struct {
  int first, second, z;
} f[N];
void add(int first, int second, int z) { f[++cnt] = {first, second, z}; }
int dfs(int first) {
  vis[first] = ++*vis;
  int lst = 0;
  for (int second : g[first]) {
    if (!vis[second]) {
      int t = dfs(second);
      if (t)
        add(first, second, t);
      else if (lst)
        add(lst, first, second), lst = 0;
      else
        lst = second;
    } else if (vis[second] > vis[first]) {
      if (lst)
        add(lst, first, second), lst = 0;
      else
        lst = second;
    }
  }
  return lst;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u = rd(), v = rd();
    g[u].push_back(v), g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; ++i)
    printf("%d %d %d\n", f[i].first, f[i].second, f[i].z);
}
