#include <bits/stdc++.h>
using namespace std;
vector<int> V[200098];
bool vis[200098] = {0};
bool B = 0;
void DFS(int i, int I, int b) {
  if (i == I && b > 2) {
    B = 1;
    return;
  }
  if (vis[i]) return;
  vis[i] = 1;
  if (V[i].size() > 2) {
    B = 0;
    return;
  }
  for (int j = 0; j < V[i].size(); j++) {
    DFS(V[i][j], I, b + 1);
  }
}
int main() {
  int n, m, x, z;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> z;
    V[x].push_back(z);
    V[z].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    DFS(i, i, 0);
    if (B) ans++;
    B = 0;
  }
  cout << ans;
}
