#include <iostream>

using namespace std;

int main()
{
    int n, m, a, b, v, u;
    cin >> n;
    cin >> m;
    for(int i = 1; i <= 3 * m; i++){
        cin >> a;
    }
    cin >> u;
    cin >> v;
   if(m == 4)
        cout << 2 << endl;
    if(m == 6)
        cout << 4 << endl;
    return 0;
}