#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 29;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
int N, M;
bool used[MAX_N];
vector<int> G[MAX_N];
int depth[MAX_N];
vector<tuple<int, int, int>> ans;
bool dfs(int v, int p, int d) {
  used[v] = true;
  depth[v] = d;
  vector<int> vs;
  for (int i = int(0); i < int((int)(G[v]).size()); i++) {
    int n = G[v][i];
    if (n == p) continue;
    if (used[n]) {
      if (depth[n] < depth[v]) vs.push_back(n);
    } else {
      if (dfs(n, v, d + 1)) vs.push_back(n);
    }
  }
  vs.push_back(p);
  for (int i = int(0); i < int((int)(vs).size() / 2); i++) {
    if (vs[i * 2 + 1] == -1 || vs[i * 2] == -1) continue;
    ans.push_back(make_tuple(vs[i * 2], v, vs[i * 2 + 1]));
  }
  return (int)(vs).size() % 2;
}
void solve() {
  cin >> N >> M;
  for (int i = int(0); i < int(M); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = int(0); i < int(N); i++) {
    if (!used[i]) dfs(i, -1, 0);
  }
  cout << (int)(ans).size() << "\n";
  for (int i = int(0); i < int((int)(ans).size()); i++) {
    int x, y, z;
    tie(x, y, z) = ans[i];
    x++;
    y++;
    z++;
    cout << x << " " << y << " " << z << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  solve();
  return 0;
}
