function Main(input) {
  input = input.split("\n");
  var N = ~~input[0];
  var A = ~~input[1];
  var B = ~~input[2];
  var C = ~~input[3];
  var D = ~~input[4];
  var E = ~~input[5];


  var AtCoder = function(N,A,B,C,D,E){
    this.move = [A,B,C,D,E];
    this.dp = [...Array(N+6).keys()].map(x => [...Array(6).keys()].map(x => 0));
    this.dp[0][0]=N;
    this.memNum = N;
  };

  AtCoder.prototype = {
    procedure: function(){
      for(var t = 0; t < this.memNum+6; t++){
        for(var i = 5; i >= 0; i--){
          if(i == 0){
            if(this.dp[t][0] <= this.move[0]){
              var x = this.dp[t][0];
            }else{
              var x = this.move[0];
            }
            this.dp[t+1][0] = this.dp[t][0]-x;
          }else if(i > 0){
            if(this.dp[t][i-1] <= this.move[i-1]){
              var x_i_1 = this.dp[t][i-1];
            }else{
              var x_i_1 = this.move[i-1];
            }
            if(this.dp[t][i]<= this.move[i]){
              var x_i = this.dp[t][i];
            }else{
              if(i == 5){
                x_i = 0;
              }else{
                var x_i = this.move[i];
              }
            }
            this.dp[t+1][i]=this.dp[t][i]+x_i_1-x_i;
          }
          if(this.dp[t][5] == this.memNum) return t;
        }
      }
    }
  }
  var atcoder = new AtCoder(N,A,B,C,D,E);
  console.log(atcoder.procedure());
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
