#include<iostream>

using namespace std;

int main(){
  int L, Gain[12], Consume[12], i, saving, month;
  while(cin >> L, L){
    for(i=0; i<12; i++){
      cin >> Gain[i] >> Consume[i];
    }
    saving = 0;
    month=0;
    while(saving < L){
      saving += Gain[month] - Consume[month];
      month+=1;
    }
    cout << month << endl;
  }
}