def solve_graph_change(n, edges):
    desired_edges = n * (n - 1) // 2
    if len(edges) == desired_edges:
        return []  # Графы идентичны, операции не нужны
    elif len(edges) > desired_edges:
        return None  # Невозможно получить желаемый граф

    actions = []
    while len(edges) < desired_edges:
        a, b, c = find_combination(n, edges)
        edges = perform_action(edges, a, b, c)
        actions.append((a, b, c))
    
    return actions

def find_combination(n, edges):
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if (a, b) not in edges and (b, c) not in edges and (a, c) in edges:
                    return a, b, c

def perform_action(edges, a, b, c):
    edges.discard((a, b))
    edges.discard((b, c))
    edges.add((a, c))
    return edges

n = int(input())
m = int(input())
edges = set()
for _ in range(m):
    a, b = map(int, input().split())
    edges.add((a, b))
    edges.add((b, a))

actions = solve_graph_change(n, edges)
if actions is None:
    print("NO")
else:
    print("YES")
    print(len(actions))
    for action in actions:
        print(*action)
