#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long a, long long p) { return power(a, p - 2, p); }
long long gcd(long long x, long long y) {
  if (x == 0 || y == 0) {
    return max(y, x);
  }
  return gcd(y % x, x);
}
class triple {
 public:
  long long a, b, c;
  triple(long long aa, long long bb, long long cc) { a = aa, b = bb, c = cc; }
};
vector<long long> edge[200005];
long long used[200007];
vector<triple> ans;
long long dfs(long long cur) {
  used[cur] = 1;
  long long left = -1;
  for (auto p : edge[cur]) {
    if (used[p] == 1) continue;
    long long nw = p;
    if (!used[p]) {
      long long temp = dfs(p);
      if (temp != -1) {
        triple pp(cur, p, temp);
        ans.push_back(pp);
        nw = -1;
      }
    }
    if (nw != -1) {
      if (left != -1) {
        triple pp(p, cur, left);
        ans.push_back(pp);
        left = -1;
      } else
        left = nw;
    }
  }
  used[cur] = 2;
  return left;
}
void solve() {
  long long n, m;
  scanf("%lld %lld", &(n), &(m));
  for (long long i = 0; i < m; i++) {
    long long x, y;
    scanf("%lld %lld", &(x), &(y));
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    if (used[i] == 0) {
      dfs(i);
    }
  }
  cout << ans.size() << endl;
  for (auto p : ans) {
    cout << p.a << ' ' << p.b << ' ' << p.c << endl;
  }
}
int main() { solve(); }
