#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) int N,K; bool isok(vector a) { REP(i,a.size()) { if (a[i] != i) return false; } return true; } signed main() { cin >> N>>K; vector amida(N); REP(i,N) amida[i] = i; vector x(K); int y; REP(i,K) { cin >> x[i] >> y; swap(amida[x[i]-1], amida[x[i]]); } int cnt = 0; vector tmp(N); REP(i,N) tmp[i] = i; while(true) { cnt++; vector tmp2(N); REP(i,N) { tmp2[i] = tmp[amida[i]]; } if (isok(tmp2)) break; tmp = tmp2; } cout << cnt << endl; return 0; }