#include<iostream>
using namespace std;
int main(){

  int a,b;

  while(1){
    
    cin >>a;
    
    if( a == 0 )break;

    b=a/4;

    if( a%4 != 0 ){
      b++;
    }

    cout <<b-1<<endl;
    
  }
  
  return 0;
}