#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
vector<pair<int, int>> adj[MAXN];
int tin[MAXN], low[MAXN], timer;
vector<int> bridges;
void dfs(int v, int p, int& result) {
tin[v] = low[v] = ++timer;
for (auto edge : adj[v]) {
int to = edge.first;
int id = edge.second;
if (to == p) continue;
if (tin[to]) {
low[v] = min(low[v], tin[to]);
} else {
dfs(to, v, result);
low[v] = min(low[v], low[to]);
if (low[to] > tin[v] && (to == n || v == n)) {
result = id;
}
}
}
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
adj[a].emplace_back(b, i + 1);
adj[b].emplace_back(a, i + 1);
}
int result = 0;
dfs(1, -1, result);
cout << result << endl;
return 0;
}