import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = sc.nextLong();

		long h = minN(a,b,c,d,e);
		long ans = (n+h-1)/h;
		out.println(ans+4);
		out.flush();
	}

	private static int INF = (int)1e8;
	private static long INFL = (long)1e17;
	private static int e97 = (int)1e9 + 7;

	private static int abs(int a){
	    return (a>=0) ? a: -a;
	}
	private static long abs(long a){
	    return (a>=0) ? a: -a;
	}

	private static int min(int a, int b){
	    return (a>b) ? b : a;
	}
	private static long min(long a, long b){
	    return (a>b) ? b : a;
	}

	private static int max(int a, int b){
		return (a>b) ? a : b;
	}
	private static long max(long a, long b){
		return (a>b) ? a : b;
	}

	private static int minN(int... ins){
		int min = ins[0];
		for(int i=1; i<ins.length; i++){
			if(ins[i] < min) min = ins[i];
		}
		return min;
	}
	private static int maxN(int... ins){
		int max = ins[0];
		for(int i=1; i<ins.length; i++){
			if(ins[i] > max) max = ins[i];
		}
		return max;
	}
	private static long minN(long... ins){
		long min = ins[0];
		for(int i=1; i<ins.length; i++){
			if(ins[i] < min) min = ins[i];
		}
		return min;
	}
	private static long maxN(long... ins){
		long max = ins[0];
		for(int i=1; i<ins.length; i++){
			if(ins[i] > max) max = ins[i];
		}
		return max;
	}

	private static int minExAd(int[] dt, int ad){
	int min=Integer.MAX_VALUE;
		for(int i=0; i<dt.length; i++){
			if((i != ad) && (dt[i] < min)) min = dt[i];
		}
		return min;
	}
	private static long minExAd(long[] dt, int ad){
	long min=Long.MAX_VALUE;
		for(int i=0; i<dt.length; i++){
			if((i != ad) && (dt[i] < min)) min = dt[i];
		}
		return min;
	}
	private static int minExVal(int[] dt, int ex_val){
	int min=Integer.MAX_VALUE;
		for(int i=0; i<dt.length; i++){
			if((dt[i] != ex_val) && (dt[i] < min)) min = dt[i];
		}
		return min;
	}
	private static long minExVal(long[] dt, long ex_val){
	long min=Long.MAX_VALUE;
		for(int i=0; i<dt.length; i++){
			if((dt[i] != ex_val) && (dt[i] < min)) min = dt[i];
		}
		return min;
	}

	private static boolean same3(long a, long b, long c){
	if(a!=b) return false;
	if(b!=c) return false;
	if(c!=a) return false;
	return true;
	}
	private static boolean dif3(long a, long b, long c){
	if(a==b) return false;
	if(b==c) return false;
	if(c==a) return false;
	return true;
	}

	private static int factorial(int n) {
		int ans=1;
		for(int i=n; i>0; i--){
			ans*=i;
		}
		return ans;
	}

	private static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}

	private static int pow2(int in){
		return in*in;
	}
	private static long pow2(long in){
		return in*in;
	}

	private static int getDigit2(long num){
		long cf = 1;
		int d=0;
		while(num >= cf){
			d++;
			cf = 1<<d;
		}
		return d; //numはd桁の数で、2^dより小さい
	}

	private static int getDigit10L(long num){
		long cf = 1;
		int d=0;
		while(num >= cf){
			d++;
			cf*=10;
		}
		return d; //numはd桁の数で、10^dより小さい
	}

	private static boolean isINF(int in){
	if((in*20)>INF) return true;
	else return false;
	}
	private static boolean isINFL(long in){
	if((in*10000)>INFL) return true;
	else return false;
	}

	private static long pow10E97(long ob, int soeji){
		if(soeji==2) return (ob*ob)%e97;

		int d = getDigit2(soeji);
		long[] ob_pow_2pow = new long[d];

		ob_pow_2pow[0] = ob;
		for(int i=1; i<d; i++){
			ob_pow_2pow[i] = (ob_pow_2pow[i-1]*ob_pow_2pow[i-1])%e97;
		}

		long ans=1;
		for(int i=d-1; i>=0; i--){
			if(soeji >= (1<<i)){
				soeji -= (1<<i);
				ans = (ans*ob_pow_2pow[i])%e97;
			}
 		}

		return ans;
	}

	private static int flag(int pos){
	    return (1<<pos);
	}
	private static boolean isFlaged(int bit, int pos){
    	if((bit&(1<<pos)) > 0) return true;
    	else return false;
	}
	private static int deflag(int bit, int pos){
	    return bit&~(1<<pos);
	}
	private static void showflag(int bit){
    	for(int i=0; i<getDigit2(bit); i++){
        	if(isFlaged(bit,i)) System.out.print("O");
        	else System.out.print(".");
    	}
	}

	private static void fill(boolean[] ob, boolean res){
		for(int i=0; i<ob.length; i++){
			ob[i] = res;
		}
		return;
	}
	private static void fill(int[] ob, int res){
		for(int i=0; i<ob.length; i++){
			ob[i] = res;
		}
		return;
	}
	private static void fill(long[] ob, long res){
		for(int i=0; i<ob.length; i++){
			ob[i] = res;
		}
		return;
	}
	private static void fill(char[] ob, char res){
		for(int i=0; i<ob.length; i++){
			ob[i] = res;
		}
		return;
	}
	private static void fill(int[][] ob, int res){
		for(int i=0; i<ob.length; i++){
			for(int j=0; j<ob[0].length; j++){
				ob[i][j] = res;
			}
		}
		return;
	}
	private static void fill(long[][] ob, long res){
		for(int i=0; i<ob.length; i++){
			for(int j=0; j<ob[0].length; j++){
				ob[i][j] = res;
			}
		}
		return;
	}
	private static void fill(char[][] ob, char res){
		for(int i=0; i<ob.length; i++){
			for(int j=0; j<ob[0].length; j++){
				ob[i][j] = res;
			}
		}
		return;
	}
	private static void fill(int[][][] ob, int res){
		for(int i=0; i<ob.length; i++){
			for(int j=0; j<ob[0].length; j++){
				for(int k=0; k<ob[0][0].length; k++){
			ob[i][j][k] = res;
				}
			}
		}
		return;
	}
	private static void fill(long[][][][] ob, long res){
		for(int i=0; i<ob.length; i++){
			for(int j=0; j<ob[0].length; j++){
				for(int k=0; k<ob[0][0].length; k++){
				for(int l=0; l<ob[0][0][0].length; l++){
				ob[i][j][k][l]=res;
				}
				}
			}
		}
		return;
	}

	static void show_b2d_array(boolean[][] dt, int lit_x, int lit_y){
		for(int i=0; i<dt[0].length; i++){
			for(int j=0; j<dt.length; j++){
				if((i==lit_y) && (j==lit_x)) System.out.print("X");
				else if(dt[j][i]) System.out.print("O");
				else System.out.print(".");
			}
			System.out.println();
		}
	}
	static void show_L2(long[][] dt, String cmnt){
		PrintWriter out = new PrintWriter(System.out);
		for(int i=0; i<dt[0].length; i++){
			for(int j=0; j<dt.length; j++){
				out.print(dt[j][i]+",");
			}
			out.println("<-"+cmnt+":"+i);
		}
		out.flush();
	}
	static void disp_que(ArrayDeque<Integer> dt){		//上手くいかなかった時用
		int a=0;
		while(dt.size()>0){
			a=dt.removeLast();
			System.out.print(a);
		}
		System.out.println("\n");
	}

	private static void nextPerm(ArrayList<Integer> former){
		int pivot=-1;
		int ln = former.size();
		for(int i = ln; i>1; i--){
			if(former.get(i-2) < former.get(i-1)){
				pivot = i-2;
				break;
			}
		}
		if(pivot==-1){
		former = null;
		return;
		}
		int pivot_fig = former.get(pivot);

		int min_pos=pivot+1;
		int min=former.get(min_pos);
		for(int i=ln-1; i > pivot+1; i--){
			if((former.get(i) < min)&&(former.get(i) > pivot_fig)){
				min_pos=i;
				min=former.get(min_pos);
			}
		}
		Collections.swap(former, pivot, min_pos);
		Collections.sort(former.subList(pivot+1, ln));
		return;
	}

	public static int binarySearch(int[] dt, int target){
		int left=0, right=dt.length-1;
		int mid=-1;
		while(left<=right){
			mid = (right+left)/2;
			if(dt[mid] == target) return mid;
			if(dt[mid] < target) left=mid+1;
			else right=mid-1;
		}
		return -1;
	}
	public static int binarySearchMax(long[] dt, long target){
		int left=-1, right=dt.length;
		int mid=-1;

		while((right-left)>1){
			mid = left + (right-left)/2;
			if(dt[mid] < target) left=mid;
			else right=mid;
		}
		return left;//target未満の最大のaddress
	}

	private static int dfs2(boolean[][] state, int x, int y, int depth){		//薄氷渡り
		int[] tmpltX = {1,-1,0,0};
		int[] tmpltY = {0,0,1,-1};
		int newX = -1, newY = -1;

		state[x][y] = false;
		depth++;

		int maxDunder_this_brunch = depth, tmpD=0;
		for(int i=0; i < 4; i++){
			newX = x+tmpltX[i];
			newY = y+tmpltY[i];
			if((newX >= 0) && (newY >= 0) && (newX < state.length) && (newY < state[0].length) && state[newX][newY]) tmpD = dfs2(state, newX, newY, depth);
			if(tmpD > maxDunder_this_brunch) maxDunder_this_brunch=tmpD;
		}
		state[x][y] = true;
		return maxDunder_this_brunch;
	}

static class Edge{
    int v2;
    long weight;
    public Edge(int vn, long w){
        this.v2 = vn;
        this.weight = w;
    }
}

static class Comparator_Edge implements Comparator<Edge>{
    public int compare(Edge a, Edge b){
        if(a.weight>b.weight){
            return 1;
        }else if(a.weight<b.weight){
            return -1;
        }
        return 0;
    }
}
static class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		long a,b,c,d,e,n,ans = 0;
		String str;
		str = bf.readLine();
		n = Long.parseLong(str);
		str = bf.readLine();
		a = Long.parseLong(str);
		long temp = a;
		str = bf.readLine();
		b = Long.parseLong(str);
		if(temp > b) {
			temp = b;
		}
		str = bf.readLine();
		c = Long.parseLong(str);
		if(temp > c) {
			temp = c;
		}
		str = bf.readLine();
		d = Long.parseLong(str);
		if(temp > d) {
			temp = d;
		}
		str = bf.readLine();
		e = Long.parseLong(str);
		if(temp > e) {
			temp = e;
		}
		ans = n/temp + 4;
		if(n%temp != 0) {
			ans++;
		}
		System.out.println(ans);
	}
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        ArrayList<Long> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(sc.nextLong());
        }
        long min = Collections.min(list);
        if(min >= n) {
            System.out.println(5);
        } else {
            long tmp = (n % min) % 2;
            long ans = 0;
            if(tmp != 0) {
                ans = (n / min) + 5;
            } else {
                ans = (n / min) + 4;
            }
            System.out.println(ans);
        }
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        ArrayList<Long> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(sc.nextLong());
        }
        long min = Collections.min(list);
        if(min >= n) {
            System.out.println(5);
        } else {
            long ans = (n / min) + 5;
            System.out.println(ans);
        }
    }
}


import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long a[];
		a = new long[5];
		a[0] = Long.parseLong(sc.next());
		a[1] = Long.parseLong(sc.next());
		a[2] = Long.parseLong(sc.next());
		a[3] = Long.parseLong(sc.next());
		a[4] = Long.parseLong(sc.next());

		// 最も輸送人数の少ない乗り物の、輸送人数をminとする
		long min = a[0];
		for (int i = 1; i <= 4; i++) {
			if (a[i] < min) {
				min = a[i];
			}
		}

		// min人ずつ流すので
		System.out.println((n / min) + 5);

	}

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   long long n;
   array<long long, 5> x;
   cin >> n;
   for(int i = 0; i < x.size(); i++){
      cin >> x[i];
   }
   long long min_x = *min_element(x.begin(), x.end());
   cout << (n + min_x - 1)/min_x + 4  << endl;
   return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#include<cstring>
#define ll long long
#define sci(a) scanf("%d",&a)
#define scl(a) scanf("%I64d",&a)
#define scs(a) scanf("%s",a)
#define pri(a) printf("%d",a)
#define prl(a) printf("%I64d",a)
#define prc(a) printf("%c",a)
const int N=1e5+5;
const int M=1e5+5;
const ll INF=1e15+7;
const double PI=acos(-1);
using namespace std;
ll n,a[10];
int main(){
	cin>>n;
	for(int i=0;i<5;++i) cin>>a[i];
	ll small=INF;
	for(int i=0;i<5;++i) if(small>a[i]) small=a[i];
	ll ans=4;
	ans+=n/small;
	if(n%small!=0) ans++;
	cout<<ans;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#include<cstring>
#define ll long long
#define sci(a) scanf("%d",&a)
#define scl(a) scanf("%I64d",&a)
#define scs(a) scanf("%s",a)
#define pri(a) printf("%d",a)
#define prl(a) printf("%I64d",a)
#define prc(a) printf("%c",a)
const int N=1e5+5;
const int M=1e5+5;
const ll INF=1e15+7;
const double PI=acos(-1);
using namespace std;
ll n,a[10];
int main(){
	scanf("%lld",&n);
	for(int i=0;i<5;++i) scanf("%lld",&a[i]);
	ll small=INF;
	for(int i=0;i<5;++i) if(small>a[i]) small=a[i];
	ll ans=4;
	ans+=n/small;
	if(n%small!=0) ans++;
	printf("%lld",ans);
}


#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> V(5);
  for (int i=0; i<5; i++) {
    cin >> V[i];
  }
  ll S=0;

  int Ve=V[0];
  for (int i=1; i<5; i++) {
    if (V[i]<Ve) {
      Ve=V[i];
    }
  }

  cout << (N-1)/Ve+5 << endl;

}


#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> V(5), E(1,0);
  for (int i=0; i<5; i++) {
    cin >> V[i];
  }
  ll S=0;

  int Ve=V[0];
  for (int i=1; i<5; i++) {
    if (V[i]<Ve) {
      E.push_back(i);
      Ve=V[i];
    }
  }
  E.push_back(5);

  //S+=(N-1)/V[i]+1+1;
  for (int i=1; i<E.size(); i++) {
    S+=E[i]-E[i-1]-1+((N-1)/V[E[i-1]]+1);
    //cout << S << endl;
    if (i>1) {S--;}
  }
  cout << S << endl;

}


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  ll w = min({a,b,c,d,e});
  ll pls;
  if(n <= w){
    cout << 5 << endl;
    return 0;
  }
  ll ans = n/w;

  ans += 5;
  cout << ans << endl;
}


long long n,x,i,ans;main(){
scanf("%lld%lld",&n,&x);
ans=(n-1)/x;
for(i=0;i<4;i++){scanf("%lld",&x);ans=(ans>(n-1)/x?ans:(n-1)/x); }
printf("%lld",5+ans);}


#include <stdio.h>
long long n,x,i,ans;
int main(){
scanf("%lld%lld",&n,&x);
ans=(n-1)/x;
for(i=0;i<4;i++){scanf("%lld",&x);ans=(ans>(n-1)/x?ans:(n-1)/x); }
printf("%lld",5+ans);
return 0;
}


#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC123C
int main(void) {
  int i;
  long long n, abc[5], min=1e15;
  scanf("%lld", &n);
  for(i=0; i<5; i++){
    scanf("%lld", &abc[i]);
    min=min>abc[i] ? abc[i] : min;
  }
  printf("%lld", 5+(n-1)/min);
}


#include<stdio.h>
int main(void){

	unsigned long long int a[5],k,i,x,o=0,m=0;

	scanf("%d",&k);
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);

	for(i=0;i<5;i++){
		x=(k/a[i]);
		if(x>o){
			m+=(x-o);
			o=x;
		}
	}
	m+=5;
	printf("%d",m);
	return(0);
}


#include<stdio.h>
int main(void){

	unsigned int a[5],k,i,x,o=0,m=0;

	scanf("%d",&k);
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);

	for(i=0;i<5;i++){
		x=(k/a[i]);
		if(x>o){
			m+=(x-o);
			o=x;
		}
	}
	m+=5;
	printf("%d",m);
	return(0);
}


#include<stdio.h>
int main(void){

	unsigned int a[5],k,i,x,o=0,m=0;

	scanf("%d",&k);
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);

	for(i=0;i<5;i++){
		x=(k/a[i])+1;
		if(x>o){
			m+=(x-o);
			o=x;
		}
	}
	m+=4;
	printf("%d",m);
	return(0);
}


function main(x) {
    console.log(4+Math.ceil(x[0]/Math.min(x[1],x[2],x[3],x[4],x[5])));
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));


function Main(input){
  var data = input.split("\n");
  var move = Math.min(data[1], data[2], data[3], data[4], data[5]);
  console.log(Math.ceil(data[0]/move)+4);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    tmp = tmp.map(Number);

    N = tmp[0];
    m = Math.min(tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]);
    answer = 4 + Math.ceil(N/m);
    console.log(answer);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
  const formatted_input = input.split('\n').map(x => parseInt(x));

  const N = formatted_input[0];
  var necks = [];
  for(var i=1;i<=5;i++){
    necks.push(formatted_input[i]);
  }
  const bottle_neck = Math.min(...necks);
  const bottle_neck_time = Math.floor(N/bottle_neck)+1;

  var result = 4 + bottle_neck_time;

//  console.log(N);
//  console.log(bottle_neck);
//  console.log(bottle_neck_time);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function MainC(input) {
	input = input.split("\n");
	var n = input.shift();
	var min = Infinity;
　for(var i = 0; i < 5; i++){
		if( input[i] < min){
			min = input[i];
		}
	}
  var totalTime = Math.ceil(n / min) + 4;

	console.log('%d',totalTime);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
MainC(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
  tile = input.split('')
  changeCount = 0
  changeFlag = false
  for (let index = 1; index < tile.length; index++) {
    if(tile[index] == tile[index-1] && !changeFlag){
      changeFlag = true
      changeCount ++
    }
    else if(tile[index] != tile[index-1] && changeFlag){
      changeCount ++
    }else{
      changeFlag = false
    }
    return;
  }

  }
  Main(require("fs").readFileSync("/dev/stdin","utf-8"));


package main

import (
	"fmt"
)

func main() {

	var N uint64
	var A[5] uint64

	fmt.Scanf("%v", &N)
	fmt.Scanf("%v", &A[0]) // 0 -> 1
	fmt.Scanf("%v", &A[1]) // 0 -> 1
	fmt.Scanf("%v", &A[2]) // 0 -> 1
	fmt.Scanf("%v", &A[3]) // 0 -> 1
	fmt.Scanf("%v", &A[4]) // 0 -> 1

	num := make([]uint64, 6)
	num[0] = N

	minIdx := 0
	min := A[0]
	for i := 1; i < 5; i++ {
		if A[i] < min {
			min = A[i]
			minIdx = i
		}
	}
	// minの左までを足す
	var t uint64
	for i := 0; i < minIdx; i++ {
		t ++
	}
	// minの分を足す
	t += N / A[minIdx]
	if N % A[minIdx] != 0 {
		t++
	}
	// minの右を足す
	for i := minIdx + 1; i < 5; i++ {
		t ++
	}
	fmt.Printf("%v\n", t)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func swap(a int64, b int64) (int64, int64) {
	return b, a
}

func gcd(a int64, b int64) int64 {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return gcd(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func nextLong() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextLong()
	A := nextLong()
	minnum := A
	B := nextLong()
	minnum = min(minnum, B)
	C := nextLong()
	minnum = min(minnum, C)
	D := nextLong()
	minnum = min(minnum, D)
	E := nextLong()
	minnum = min(minnum, E)
	ans := int64(math.Ceil(float64(N)/float64(minnum)) + 4)
	fmt.Printf("%d\n", ans)
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := readi()
	A := readi()
	B := readi()
	C := readi()
	D := readi()
	E := readi()

	t := []int{A, B, C, D, E}
	sort.Ints(t)

	tmp := int(math.Ceil(float64(N) / float64(t[0])))

	fmt.Println(4 + tmp)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	min := int(1e16)
	for i := 0 ; i < 5; i++{
		var a int
		fmt.Scan(&a)
		if min > a {
			min = a
		}
	}

	fmt.Println(n/min + 5)

}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

var DEBUG = true

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO functions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbufferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbufferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func debugf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func debug(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()
	n := readll()
	cities := make([]int64, 5)
	for i := 0; i < 5; i++ {
		cities[i] = readll()
	}
	answer := solve(n, cities)
	println(answer)
}

func solve(n int64, cities []int64) int64 {
	var minCapacity int64 = 1000000000000000
	for i := 0; i < len(cities); i++ {
		minCapacity = minll(minCapacity, cities[i])
	}
	var miniutes int64 = n / minCapacity
	if minCapacity%n != 0 {
		miniutes++
	}
	miniutes += int64(len(cities) - 1)
	return miniutes
}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

var DEBUG = true

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO functions (read*() and [e]print64*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for int64eractive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbufferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int64
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbufferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int64
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int6464
func readll() int6464 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int64
func readi() int64 {
	return int64(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func print64f(f string, args ...int64erface{}) (int64, error) {
	return fmt.Fprint64f(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func print64ln(args ...int64erface{}) (int64, error) {
	return fmt.Fprint64ln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprint64f(f string, args ...int64erface{}) (int64, error) {
	return fmt.Fprint64f(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprint64ln(args ...int64erface{}) (int64, error) {
	return fmt.Fprint64ln(os.Stderr, args...)
}

func debugf(f string, args ...int64erface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprint64f(os.Stderr, f, args...)
}

func debug(args ...int64erface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprint64ln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int6464) int6464 {
	var res int6464
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int64) (int64, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int64) (int64, []int6464) {
	if N == 0 {
		N = readi()
	}
	a := make([]int6464, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int6464) int6464 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int6464) int6464 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int6464) int6464 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  int64egers that satisfy ax + by = d
func egcd(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int6464) (int6464, int6464, int6464) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int64) int64 {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int6464) int6464 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-int64eractive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when int64eractive.  Its ok to leave above int64act.
	SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()
	n := readi()
	cities := make([]int64, 5)
	for i := 0; i < 5; i++ {
		cities[i] = readi()
	}
	answer := solve(n, cities)
	print64ln(answer)
}

func solve(n int64, cities []int64) int64 {
	minCapacity := 1000000000000000
	for i := 0; i < len(cities); i++ {
		minCapacity = min(minCapacity, cities[i])
	}
	miniutes := n / minCapacity
	if minCapacity%n != 0 {
		miniutes++
	}
	miniutes += len(cities) - 1
	return miniutes
}


n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

bottleneck = [a, b, c, d, e].min

bottleneck_count, mod = n.divmod(bottleneck)
bottleneck_count += 1 unless mod.zero?

puts bottleneck_count + 4


N = gets.to_i
A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i
time_list = [A,B,C,D,E]
min = time_list.min
min_index = time_list.index(min)
puts (N/min) + (N%min==0 ? 0 : 1) + 4-min_index + min_index


n = gets.chomp.to_f
tptt = []
5.times do
  tptt.push(gets.chomp.to_i)
end

p (n / tptt.min).ceil + 4


N = gets.to_i
AE = 5.times.map{|_| gets.to_i}

min = AE.min
p N / min + 5


n = gets.to_i
array = []
5.times do
  array << gets.to_i
end

x = n % array.min

if n < array.min
  puts 5
else
  puts ceil(x + 4)
end


n = gets.to_i
array = []
5.times do
  array << gets.to_i
end

x = n % array.min

if n < array.min
  puts 5
else
  puts x + 4
end


fn main() {
    let n = read::<usize>();
    let mut abcde: Vec<usize> = vec![0; 5];
    let mut idx = 0;
    let mut mi = usize::max_value();
    for i in 0..5 {
        let tmp = read::<usize>();
        if mi > tmp {
            mi = tmp;
            idx = i;
        }
    }

    let ret = if n % mi == 0 {
        (n / mi)
    } else {
        (n / mi) + 1
    };
    println!("{}", ret + 4);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut min_capacity: usize = iterator.next().unwrap().parse().unwrap();
    min_capacity = min(min_capacity, iterator.next().unwrap().parse().unwrap());
    min_capacity = min(min_capacity, iterator.next().unwrap().parse().unwrap());
    min_capacity = min(min_capacity, iterator.next().unwrap().parse().unwrap());
    min_capacity = min(min_capacity, iterator.next().unwrap().parse().unwrap());

    if min_capacity >= n {
        return "5".to_string()
    }

    if n % min_capacity == 0 {
        return format!("{}", 5 + (n / min_capacity - 1));
    }

    return format!("{}", 5 + (n / min_capacity));
}


#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N: usize,
        A: usize,
        B: usize,
        C: usize,
        D: usize,
        E: usize,
    }
    let &m = [A, B, C, D, E].into_iter().min().unwrap();
    println!("{}", 4 + (N as f64 / m as f64).ceil() as usize);
}


use num_bigint::BigInt;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: BigInt,
        a: BigInt,
        b: BigInt,
        c: BigInt,
        d: BigInt,
        e: BigInt,
    }
    let mut array = [a, b, c, d, e];
    array.sort();
    let min = &array[0];

    println!("{}", n / min + 5);
}


#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
    }
    let mut array = [a, b, c, d, e];
    array.sort();

    println!("{}", n / array[0] + 5);
}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        route: [usize;5],
    }

    let mut min_value = route[0];
    for i in route {
        min_value = std::cmp::min(min_value, i);
    }

    let ans = 4 + n/min_value + 1;

    println!("{}", ans);

}


var i:Int{return Int(readLine()!)!};let N=i,n=[i,i,i,i,i].minElement()!;print(4+(N+n-1)/n)


var i:Int{return Int(readLine()!)!};let N=i,n=min(i,i,i,i,i);print(4+(N+n-1)/n)


var i:Int{return Int(readLine()!)!}
let N = i
let n = [i,i,i,i,i].minElement()!
print(4+(N+n-1)/n)


import Foundation

class City {

    private let delay: Int
    private let initial: Int
    private let output: Int
    private let prev: City?

    init(delay: Int, initial: Int, output: Int, prev: City?) {
        self.delay = delay
        self.initial = initial
        self.output = output
        self.prev = prev
    }

    func outputPerMin() -> Int {
        if let prev = prev {
            return min(prev.outputPerMin(), output)
        } else {
            return output
        }
    }

    func outputTimes() -> Int {
        var sum = initial
        if let prev = prev {
            sum += prev.outputPerMin() * prev.outputTimes()
        }
        let output = outputPerMin()
        return Int(ceil(Double(sum) / Double(output)))
    }

    func totalTime() -> Int {
        return delay + outputTimes()
    }
}

let N = Int(readLine()!)!

var cities: [City] = []
var prev: City?
for i in 0 ..< 5 {
    let output = Int(readLine()!)!
    let city = City(
        delay: i,
        initial: i == 0 ? N : 0,
        output: output,
        prev: prev)
    cities.append(city)
    prev = city
}

let answer = cities.last!.totalTime()

print(answer)


var i:Double{return Double(readLine()!)!};print(4+Int(i/min(i,i,i,i,i)+0.999))


var i:Double{return Double(readLine()!)!};print(4+Int(i/min(i,i,i,i,i)+0.99))


export class Main {
  static main(input): string {
    const [n, a, b, c, d, e]: number[] = input.split("\n").map(s => Number(s.split(" ")[0]));
    const m: number = Math.min(a, b, c, d, e);
    const r: number = n % m;
    let result: number = 0;
    if (r == 0) {
      result = n / m;
    } else {
      result = (n - r) / m + 1;
    }
    return `${result + 4}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


const input = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, a, b, c, d, e] = input.split('\n').map(Number)
const min = Math.min(a, b, c, d, e)
if (n % min === 0) {
  console.log(Math.floor(n / min) + 4)
}
else {
  console.log(Math.floor(n / min) + 5)
}


function main(input) {
  const [N,A,B,C,D,E] = input.split("\n").map(v => parseInt(v));
  console.log(Math.ceil(N / Math.min(A,B,C,D,E)) + 4);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

const n = Number(input[0]);
const s = input[1];
let result = 0;
if (s.length < 2) {
    console.log(result);
} else {
    for (let i = 1; i < s.length; i++) {
        const char = s[i];
        const prevChar = s[i - 1];
        if (prevChar === "#" && char === ".") {
            result++;
        }
    }
    console.log(result);
}


const txt = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, a, b, c, d, e, gomi] = txt.split('\n').map((i: string) => { return Number(i) })
const min = [a, b, c, d, e].sort()[0]
if (n % min === 0) {
  console.log(Math.floor(n / min) + 4)
}
else {
  console.log(Math.floor(n / min) + 5)
}


const txt = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, a, b, c, d, e, gomi] = txt.split('\n').map((i: string) => { return Number(i) })
const min = [a, b, c, d, e].sort()[0]
if (min % n === 0) {
  console.log(Math.floor(n / min) + 4)
}
else {
  console.log(Math.floor(n / min) + 5)
}


import sys
from collections import deque

def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    edge = [[] for _ in range(N + 1)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        edge[u].append((v, w))
        edge[v].append((u, w))

    color = [False] * (N + 1)
    color[1] = 0
    q = deque([1])
    pass
    while q:
        u= q.popleft()
        c1 = color[u]
        for c,w in edge[u]:
            if color[c] is False:
                q.append(c)
                color[c] = (c1+w)%2

    color.pop(0)
    print(*color)

if __name__ == "__main__":
    main()


import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

def f(N):
    res = 0
    while N != 0:
        b = format(N, "b").count("1")
        N %= b
        res += 1
    return res

def main():
    N = int(input())
    F = [[] for _ in range(N)]

    for _ in range(N - 1):
        u, v, w = read_values()
        u -= 1
        v -= 1
        F[u].append((v, w % 2))
        F[v].append((u, w % 2))

    D = [0] * N
    stack = [(0, 0, -1)]

    while stack:
        a, d, p = stack.pop()
        D[a] = d % 2

        for b, w in F[a]:
            if b == p:
                continue
            stack.append((b, (d + w) % 2, a))

    for d in D:
        print(d)

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0

    while q:
        v = q.popleft()

        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)

    return dist

N = int(input())
G = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append((v-1, w))
    G[v-1].append((u-1, w))

dist = bfs()
ans = [0]*N

for i in range(N):
    if dist[i]%2==0:
        ans[i] = 1

for ans_i in ans:
    print(ans_i)


from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v, w = u - 1, v - 1, w % 2
    graph[u].append([v, w])
    graph[v].append([u, w])

colors = [-1 for _ in range(N)]
stack = deque()
stack.append(0)
colors[0] = 0

while stack:
    n = stack.pop()
    for _next, w in graph[n]:
        if colors[_next] != -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append([_next])

for c in colors:
    print(c)


from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v, w = u - 1, v - 1, w % 2
    graph[u].append([v, w])
    graph[v].append([u, w])

colors = [-1 for _ in range(N)]
stack = deque()
stack.append(0)
colors[0] = 0

while stack:
    n = stack.pop()
    for _next, w in graph[n]:
        if colors[_next] == -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append([_next])

for c in colors:
    print(c)


from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v, w = u - 1, v - 1, w % 2
    graph[u].append([v, w])
    graph[v].append([u, w])

colors = [-1 for _ in range(N)]
stack = deque()
if N != 1:
    stack.append([0, graph[0][0][0], graph[0][0][1]])
colors[0] = 0

while stack:
    prev, _next, w = stack.pop()
    if colors[_next] == -1:
        if w % 2 == 0:
            color = 0
        else:
            color = 1
        colors[_next] = color
    for v1, w1 in graph[_next]:
        if colors[v1] != -1:
            continue
        stack.append([_next, v1, w + w1])

for c in colors:
    print(c)


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author cplayer
 */
public class Main {
    public static void main (String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DEvenRelation solver = new DEvenRelation();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEvenRelation {
        private Tree tree;
        private int[] used;
        private int[] color;

        public void solve (int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int[] from = new int[n - 1], to = new int[n - 1];
            long[] weight = new long[n - 1];
            for (int i = 0; i < n - 1; ++i) {
                from[i] = in.readInt() - 1;
                to[i] = in.readInt() - 1;
                weight[i] = in.readLong();
            }
            tree = Tree.createWeightedTree(n, from, to, weight);
            used = new int[n];
            color = new int[n];
            search(0, 0);
            out.separateLines(color);
        }

        private void search (int idx, int curColor) {
            color[idx] = curColor;
            used[idx] = 1;
            for (int j = tree.firstOutBound(idx); j != -1; j = tree.nextOutBound(j)) {
                int dest = tree.destination(j);
                int src = tree.source(j);
                if (used[dest] == 0) {
                    search(dest, curColor ^ (int) (tree.weight(j) % 2));
                }
            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter (OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter (Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close () {
            writer.close();
        }

        public void println (int i) {
            writer.println(i);
        }

        public void separateLines (int[] array) {
            for (int i : array) {
                println(i);
            }
        }

    }

    static abstract class Edge {
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader (InputStream stream) {
            this.stream = stream;
        }

        public int read () {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt () {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong () {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar (int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace (int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar (int ch);

        }

    }

    static class Tree {
        private int vertexCount;
        private int edgeCount;
        private int[] firstOutBound;
        private int[] nextOutBound;
        private int[] from;
        private int[] to;
        private long[] weight;
        private Edge[] edges;

        public Tree (int vertexCount, int maxEdgeCount) {
            this.vertexCount = vertexCount;
            this.edgeCount = 0;
            firstOutBound = new int[vertexCount];
            from = new int[maxEdgeCount];
            to = new int[maxEdgeCount];
            nextOutBound = new int[maxEdgeCount];
            Arrays.fill(firstOutBound, -1);
        }

        public static Tree createWeightedTree (int vertexCount, int[] from, int[] to, long[] weight) {
            Tree res = new Tree(vertexCount, from.length);
            for (int i = 0; i < from.length; ++i) {
                res.addWeightedEdge(from[i], to[i], weight[i]);
                res.addWeightedEdge(to[i], from[i], weight[i]);
            }
            return res;
        }

        public int source (int id) {
            return from[id];
        }

        public int destination (int id) {
            return to[id];
        }

        public final int firstOutBound (int vertex) {
            return firstOutBound[vertex];
        }

        public final int nextOutBound (int vertex) {
            return nextOutBound[vertex];
        }

        public long weight (int id) {
            return weight[id];
        }

        protected TreeEdge createEdge (int id) {
            return new TreeEdge(id);
        }

        protected void ensureEdgeCapacity (int edgeSize) {
            if (from.length < edgeSize) {
                int newSize = Math.max(edgeSize, 2 * from.length);
                if (edges != null) {
                    edges = resize(edges, newSize);
                }
                from = resize(from, newSize);
                to = resize(to, newSize);
                nextOutBound = resize(nextOutBound, newSize);
                if (weight != null) {
                    weight = resize(weight, newSize);
                }
            }
        }

        public int addEdge (int fromId, int toId, long weight) {
            ensureEdgeCapacity(edgeCount + 1);
            if (firstOutBound[fromId] != -1) {
                nextOutBound[edgeCount] = firstOutBound[fromId];
            } else {
                nextOutBound[edgeCount] = -1;
            }
            firstOutBound[fromId] = edgeCount;
            this.from[edgeCount] = fromId;
            this.to[edgeCount] = toId;
            if (weight != 0) {
                if (this.weight == null) {
                    this.weight = new long[from.length];
                }
                this.weight[edgeCount] = weight;
            }
            if (edges != null) {
                edges[edgeCount] = createEdge(edgeCount);
            }
            return edgeCount++;
        }

        public int addWeightedEdge (int from, int to, long weight) {
            return addEdge(from, to, weight);
        }

        private Edge[] resize (Edge[] oriEdges, int newSize) {
            Edge[] newEdges = new Edge[newSize];
            System.arraycopy(oriEdges, 0, newEdges, 0, oriEdges.length);
            return newEdges;
        }

        private long[] resize (long[] oriArr, int newSize) {
            long[] newArr = new long[newSize];
            System.arraycopy(oriArr, 0, newArr, 0, oriArr.length);
            return newArr;
        }

        private int[] resize (int[] oriArr, int newSize) {
            int[] newArr = new int[newSize];
            System.arraycopy(oriArr, 0, newArr, 0, oriArr.length);
            return newArr;
        }

        protected class TreeEdge extends Edge {
            protected int id;

            protected TreeEdge (int id) {
                this.id = id;
            }

        }

    }
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007;
	List<int[]>[] adj;
	int dp[];

	void solve() {
		int n = ni();
		dp = new int[n];

		adj = new List[n];
		for (int i = 0; i <= n - 1; i++)
			adj[i] = new ArrayList<int[]>();

		for (int i = 1; i <= n - 1; i++) {
			int u = ni() - 1;
			int v = ni() - 1;
			int w = ni();
			adj[u].add(new int[] { v, w });
			adj[v].add(new int[] { u, w });
		}

		dfs(0, -1);
		StringBuffer sb = new StringBuffer();
		for (int i : dp)
			sb.append(i).append(System.lineSeparator());

		out.print(sb);
	}

	private void dfs(int cur, int p) {
		for (int[] e : adj[cur]) {
			if (e[0] != p) {
				dp[e[0]] = (dp[cur] + e[1]) % 2;
				dfs(e[0], cur);
			}
		}
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Osmanys Alonso (osmanys@gmail.com)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        private int[] r;
        private boolean[] visited;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            Graph g = new Graph(n);
            int u, v, w;
            for (int i = 0; i < n - 1; i++) {
                u = in.readInt();
                v = in.readInt();
                w = in.readInt();
                g.addWeightedEdge(u - 1, v - 1, w);
                g.addWeightedEdge(v - 1, u - 1, w);
            }
            r = new int[n];
            visited = new boolean[n];
            go(g, 0, 0);
            for (int i = 0; i < n; i++)
                out.printLine(r[i]);
        }

        private void go(Graph g, int v, int c) {
            visited[v] = true;
            r[v] = c;
            int next;
            Edge edge;
            for (int e = g.firstOutbound(v); e != -1; e = g.nextOutbound(e)) {
                edge = g.edge(e);
                next = edge.getDestination();
                if (!visited[next])
                    go(g, next, (edge.getWeight() & 1) == 0 ? c : (c + 1) & 1);
            }
        }

    }

    static class Graph {
        public static final int REMOVED_BIT = 0;
        protected int vertexCount;
        protected int edgeCount;
        private int[] firstOutbound;
        private int[] firstInbound;
        private Edge[] edges;
        private int[] nextInbound;
        private int[] nextOutbound;
        private int[] from;
        private int[] to;
        private long[] weight;
        public long[] capacity;
        private int[] reverseEdge;
        private int[] flags;

        public Graph(int vertexCount) {
            this(vertexCount, vertexCount);
        }

        public Graph(int vertexCount, int edgeCapacity) {
            this.vertexCount = vertexCount;
            firstOutbound = new int[vertexCount];
            Arrays.fill(firstOutbound, -1);

            from = new int[edgeCapacity];
            to = new int[edgeCapacity];
            nextOutbound = new int[edgeCapacity];
            flags = new int[edgeCapacity];
        }

        public int addEdge(int fromID, int toID, long weight, long capacity, int reverseEdge) {
            ensureEdgeCapacity(edgeCount + 1);
            if (firstOutbound[fromID] != -1) {
                nextOutbound[edgeCount] = firstOutbound[fromID];
            } else {
                nextOutbound[edgeCount] = -1;
            }
            firstOutbound[fromID] = edgeCount;
            if (firstInbound != null) {
                if (firstInbound[toID] != -1) {
                    nextInbound[edgeCount] = firstInbound[toID];
                } else {
                    nextInbound[edgeCount] = -1;
                }
                firstInbound[toID] = edgeCount;
            }
            this.from[edgeCount] = fromID;
            this.to[edgeCount] = toID;
            if (capacity != 0) {
                if (this.capacity == null) {
                    this.capacity = new long[from.length];
                }
                this.capacity[edgeCount] = capacity;
            }
            if (weight != 0) {
                if (this.weight == null) {
                    this.weight = new long[from.length];
                }
                this.weight[edgeCount] = weight;
            }
            if (reverseEdge != -1) {
                if (this.reverseEdge == null) {
                    this.reverseEdge = new int[from.length];
                    Arrays.fill(this.reverseEdge, 0, edgeCount, -1);
                }
                this.reverseEdge[edgeCount] = reverseEdge;
            }
            if (edges != null) {
                edges[edgeCount] = createEdge(edgeCount);
            }
            return edgeCount++;
        }

        protected final GraphEdge createEdge(int id) {
            return new GraphEdge(id);
        }

        public final int addFlowWeightedEdge(int from, int to, long weight, long capacity) {
            if (capacity == 0) {
                return addEdge(from, to, weight, 0, -1);
            } else {
                int lastEdgeCount = edgeCount;
                addEdge(to, from, -weight, 0, lastEdgeCount + entriesPerEdge());
                return addEdge(from, to, weight, capacity, lastEdgeCount);
            }
        }

        protected int entriesPerEdge() {
            return 1;
        }

        public final int addWeightedEdge(int from, int to, long weight) {
            return addFlowWeightedEdge(from, to, weight, 0);
        }

        public final Edge edge(int id) {
            initEdges();
            return edges[id];
        }

        public final int firstOutbound(int vertex) {
            int id = firstOutbound[vertex];
            while (id != -1 && isRemoved(id)) {
                id = nextOutbound[id];
            }
            return id;
        }

        public final int nextOutbound(int id) {
            id = nextOutbound[id];
            while (id != -1 && isRemoved(id)) {
                id = nextOutbound[id];
            }
            return id;
        }

        public final int destination(int id) {
            return to[id];
        }

        public final long weight(int id) {
            if (weight == null) {
                return 0;
            }
            return weight[id];
        }

        protected final void initEdges() {
            if (edges == null) {
                edges = new Edge[from.length];
                for (int i = 0; i < edgeCount; i++) {
                    edges[i] = createEdge(i);
                }
            }
        }

        public final boolean flag(int id, int bit) {
            return (flags[id] >> bit & 1) != 0;
        }

        public final boolean isRemoved(int id) {
            return flag(id, REMOVED_BIT);
        }

        protected void ensureEdgeCapacity(int size) {
            if (from.length < size) {
                int newSize = Math.max(size, 2 * from.length);
                if (edges != null) {
                    edges = resize(edges, newSize);
                }
                from = resize(from, newSize);
                to = resize(to, newSize);
                nextOutbound = resize(nextOutbound, newSize);
                if (nextInbound != null) {
                    nextInbound = resize(nextInbound, newSize);
                }
                if (weight != null) {
                    weight = resize(weight, newSize);
                }
                if (capacity != null) {
                    capacity = resize(capacity, newSize);
                }
                if (reverseEdge != null) {
                    reverseEdge = resize(reverseEdge, newSize);
                }
                flags = resize(flags, newSize);
            }
        }

        protected final int[] resize(int[] array, int size) {
            int[] newArray = new int[size];
            System.arraycopy(array, 0, newArray, 0, array.length);
            return newArray;
        }

        private long[] resize(long[] array, int size) {
            long[] newArray = new long[size];
            System.arraycopy(array, 0, newArray, 0, array.length);
            return newArray;
        }

        private Edge[] resize(Edge[] array, int size) {
            Edge[] newArray = new Edge[size];
            System.arraycopy(array, 0, newArray, 0, array.length);
            return newArray;
        }

        protected class GraphEdge implements Edge {
            protected int id;

            protected GraphEdge(int id) {
                this.id = id;
            }

            public int getDestination() {
                return destination(id);
            }

            public long getWeight() {
                return weight(id);
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static interface Edge {
        public int getDestination();

        public long getWeight();

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;
		static List<ArrayList<Pair>> adjList;
		int[] colors;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			adjList = new ArrayList<ArrayList<Pair>>(n);
			colors = new int[n];
			for (int i = 0; i < n; ++i) {
				adjList.add(new ArrayList<Pair>());
			}
			for (int i = 0; i < n - 1; ++i) {
				int a = -1 + (int) sc.scanLong();
				int b = -1 + (int) sc.scanLong();
				int w = (int) sc.scanLong();
				adjList.get(a).add(new Pair(b, w));
				adjList.get(b).add(new Pair(a, w));
			}
			dfs(0, -1, 0);
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; ++i) {
				sb.append(colors[i]).append('\n');
			}
			System.out.println(sb);
		}

		private void dfs(int src, int par, int dist) {
			if (dist % 2 == 1 && par != -1)
				colors[src] = colors[par]^1;
			for (Pair nbrs : adjList.get(src)) {
				int id = nbrs.a;
				int w = nbrs.b;
				if (id == par)
					continue;
				dfs(id, src, w);
			}
		}

		private class Pair {
			int a, b;

			Pair(int a, int b) {
				this.a = a;
				this.b = b;
			}
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;
		static List<ArrayList<Pair>> adjList;
		int[] colors;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			adjList = new ArrayList<ArrayList<Pair>>(n);
			colors = new int[n];
			for (int i = 0; i < n; ++i) {
				adjList.add(new ArrayList<Pair>());
			}
			for (int i = 0; i < n - 1; ++i) {
				int a = -1 + (int) sc.scanLong();
				int b = -1 + (int) sc.scanLong();
				int w = (int) sc.scanLong();
				adjList.get(a).add(new Pair(b, w));
				adjList.get(b).add(new Pair(a, w));
			}
			dfs(0, -1, 0);
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; ++i) {
				sb.append(colors[i]).append('\n');
			}
			System.out.println(sb);
		}

		private void dfs(int src, int par, int dist) {
			if (dist % 2 == 1 && par != -1)
				colors[src] = colors[par];
			for (Pair nbrs : adjList.get(src)) {
				int id = nbrs.a;
				int w = nbrs.b;
				if (id == par)
					continue;
				dfs(id, src, w);
			}
		}

		private class Pair {
			int a, b;

			Pair(int a, int b) {
				this.a = a;
				this.b = b;
			}
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;
		static List<ArrayList<Pair>> adjList;
		int[] colors;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			adjList = new ArrayList<ArrayList<Pair>>(n);
			colors = new int[n];
			for (int i = 0; i < n; ++i) {
				adjList.add(new ArrayList<Pair>());
			}
			for (int i = 0; i < n - 1; ++i) {
				int a = -1 + (int) sc.scanLong();
				int b = -1 + (int) sc.scanLong();
				int w = (int) sc.scanLong();
				adjList.get(a).add(new Pair(b, w));
				adjList.get(b).add(new Pair(a, w));
			}
			dfs(0, -1, 0);
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; ++i) {
				sb.append(colors[i]).append('\n');
			}
			System.out.println(sb);
		}

		private void dfs(int src, int par, int dist) {
			if (dist % 2 == 1)
				colors[src] = 1;
			for (Pair nbrs : adjList.get(src)) {
				int id = nbrs.a;
				int w = nbrs.b;
				if (id == par)
					continue;
				dfs(id, src, w);
			}
		}

		private class Pair {
			int a, b;

			Pair(int a, int b) {
				this.a = a;
				this.b = b;
			}
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	if (ci - cn + 16 > cm) {
		int A = getcha() - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
		return A;
	}
	else {
		int A = *ci++ - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
		return A;
	}
}

int to[200001], ne[200001], he[100001];
bool d[100001], D[100001];
void dfs(int A, int prev, bool B) {
	D[A] = B;
	for (int i = he[A]; i; i = ne[i]) {
		if (prev != to[i]) dfs(to[i], A, B ^ d[i >> 1]);
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint();
	int k = 2;
	rep1(i, N - 1) {
		int x = getint();
		int y = getint();
		bool z = getint() & 1;
		to[k] = y;
		ne[k] = he[x];
		he[x] = k++;
		to[k] = x;
		ne[k] = he[y];
		he[y] = k++;
		d[i] = z;
	}

	dfs(1, 0, 0);
	const int dm = 1 << 18;
	char dn[dm], * di = dn;
	rep1(i, N) {
		*di++ = '0' + D[i];
		*di++ = '\n';
	}
	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	if (ci - cn + 16 > cm) {
		int A = getcha() - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
		return A;
	}
	else {
		int A = *ci++ - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
		return A;
	}
}

pair<pair<int, int>, int> E[200002];
int H[100001];
int D[100001];
void dfs(int A, int B) {
	if (!D[A]) {
		D[A] = B;
		for (int i = H[A]; i; i = E[i].second) {
			dfs(E[i].first.first, B + E[i].first.second);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N = getint();
	for (int i = 1; i < 2 * N - 2; i += 2) {
		int x = getint();
		int y = getint();
		int z = getint() & 1;
		E[i] = mp(mp(y, z), H[x]);
		H[x] = i;
		E[i + 1] = mp(mp(x, z), H[y]);
		H[y] = i + 1;
	}

	dfs(1, 1);
	const int dm = 1 << 18;
	char dn[dm], *di = dn;
	rep1(i, N) {
		if (D[i] & 1) *di++ = '0';
		else *di++ = '1';
		*di++ = '\n';
	}
	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}


#include <bits/stdc++.h>

class kin{
public:
	inline void open(FILE *,int);
	inline void close(void);
	inline void scan(void);
	inline kin &operator>(char &);
	inline kin &operator>(int &);
	inline kin &operator>(long long &);
	inline kin &operator>(double &);
	inline kin &operator>(long double &);
	inline kin &operator>(char *);
	template<class T>
	inline void get(T *,int);
private:
	FILE *fp;
	char *buf;
	int siz;
	int idx;
}in;

class kout{
public:
	inline void open(FILE *,int);
	inline void close(void);
	inline void print(void);
	inline kout &operator<(char);
	inline kout &operator<(int);
	inline kout &operator<(long long);
	inline kout &operator<(double);
	inline kout &operator<(long double);
	inline kout &operator<(const char *);
	template<class T>
	inline void put(T *,int,char,char);
private:
	FILE *fp;
	char *buf;
	int siz;
	int idx;
}out;

template<class E>
class edgeset{
public:
	inline void open(int,int);
	inline void close(void);
	inline int first(int);
	inline int next(int);
	inline void add(int,E);
	inline E &operator[](int);
	inline int vsize(void);
	inline int esize(void);
	inline edgeset();
	inline edgeset(int,int);
private:
	int sizv;
	int size;
	int *idxf;
	int *idxn;
	E *dat;
};

struct ds{
	int u;
	int v;
	int w;
};
edgeset<ds> g;
int c[100001];

inline void dfs(ds &e,long long x){
	x+=(long long)e.w;
	if(x&1LL) c[e.v]=1;
	for(int i=g.first(e.v);i!=-1;i=g.next(i)){
		if(g[i].v!=e.u) dfs(g[i],x);
	}
	return;
}

int main(int argc,char **argv){
	in.open(stdin,512);
	out.open(stdout,512);
	in.scan();
	int n;
	in>n;
	g.open(n+1,(n-1)*2);
	for(int i=1;i<n;++i){
		int p,q,r;
		in>p>q>r;
		g.add(p,(ds){p,q,r});
		g.add(q,(ds){q,p,r});
	}
	ds s=(ds){0,1,0};
	dfs(s,0LL);
	out.put(&c[1],n,'\n','\n');
	out.print();
	in.close();
	out.close();
	return 0;
}

inline void kin::open(FILE *fparg,int sizarg){
	fp=fparg;
	buf=new char[sizarg];
	siz=sizarg;
	idx=0;
	return;
}
inline void kin::close(void){
	fp=nullptr;
	delete[] buf;
	buf=nullptr;
	siz=0;
	idx=0;
	return;
}
inline void kin::scan(void){
	int readsiz=(int)std::fread((void *)buf,(std::size_t)1,(std::size_t)siz,fp);
	if(readsiz!=siz) buf[readsiz]='\x00';
	idx=0;
	return;
}
inline kin &kin::operator>(char &var){
	if(!buf[idx]){
		var='\x00';
		return *this;
	}
	var=buf[idx];
	if(++idx==siz) scan();
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(int &var){
	if(!buf[idx]){
		var=0;
		return *this;
	}
	int sign=-1;
	if(buf[idx]=='-'){
		sign=1;
		if(++idx==siz) scan();
	}
	var=0;
	while(buf[idx]>='0'){
		var=var*10-(int)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(long long &var){
	if(!buf[idx]){
		var=0LL;
		return *this;
	}
	long long sign=-1LL;
	if(buf[idx]=='-'){
		sign=1LL;
		if(++idx==siz) scan();
	};
	var=0LL;
	while(buf[idx]>='0'){
		var=var*10LL-(long long)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(double &var){
	if(!buf[idx]){
		var=0.0;
		return *this;
	}
	double sign=-1.0;
	if(buf[idx]=='-'){
		sign=1.0;
		if(++idx==siz) scan();
	}
	var=0.0;
	while(buf[idx]>='0'){
		var=var*10.0-(double)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	if(buf[idx]=='.'){
		if(++idx==siz) scan();
		double dig=1.0;
		while(buf[idx]>='0'){
			var-=(double)(buf[idx]-'0')*(dig/=10.0);
			if(++idx==siz) scan();
		}
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(long double &var){
	if(!buf[idx]){
		var=0.0L;
		return *this;
	}
	long double sign=-1.0L;
	if(buf[idx]=='-'){
		sign=1.0L;
		if(++idx==siz) scan();
	}
	var=0.0L;
	while(buf[idx]>='0'){
		var=var*10.0L-(long double)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	if(buf[idx]=='.'){
		if(++idx==siz) scan();
		long double dig=1.0L;
		while(buf[idx]>='0'){
			var-=(long double)(buf[idx]-'0')*(dig/=10.0L);
			if(++idx==siz) scan();
		}
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(char *str){
	if(!buf[idx]){
		str[0]='\x00';
		return *this;
	}
	int ptr=0;
	while(buf[idx]>='!'){
		str[ptr++]=buf[idx];
		if(++idx==siz) scan();
	}
	str[ptr]='\x00';
	if(++idx==siz) scan();
	return *this;
}
template<class T>
inline void kin::get(T *arr,int num){
	for(int i=0;i<num;++i) (*this)>arr[i];
	return;
}

inline void kout::open(FILE *fparg,int sizarg){
	fp=fparg;
	buf=new char[sizarg];
	siz=sizarg;
	idx=0;
	return;
}
inline void kout::close(void){
	fp=nullptr;
	delete[] buf;
	buf=nullptr;
	siz=0;
	idx=0;
	return;
}
inline void kout::print(void){
	std::fwrite((void *)buf,(std::size_t)1,(std::size_t)idx,fp);
	idx=0;
	return;
}
inline kout &kout::operator<(char val){
	buf[idx]=val;
	if(++idx==siz) print();
	return *this;
}
inline kout &kout::operator<(int val){
	if(val<0){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1;
	char dig[10];
	int ptr=0;
	do{
		int tmp=val/10;
		dig[ptr++]=(char)-(val-tmp*10)+'0';
		val=tmp;
	}while(val);
	while(ptr--){
		buf[idx]=dig[ptr];
		if(++idx==siz) print();
	}
	return *this;
}
inline kout &kout::operator<(long long val){
	if(val<0LL){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1LL;
	char dig[19];
	int ptr=0;
	do{
		long long tmp=val/10LL;
		dig[ptr++]=(char)-(val-tmp*10LL)+'0';
		val=tmp;
	}while(val);
	while(ptr--){
		buf[idx]=dig[ptr];
		if(++idx==siz) print();
	}
	return *this;
}
inline kout &kout::operator<(double val){
	if(val<0.0){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1.0;
	double dig=1.0;
	while(val/dig<=-10.0) dig*=10.0;
	int tmp;
	while(dig>=1.0){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(double)tmp*dig;
		dig/=10.0;
	}
	buf[idx]='.';
	if(++idx==siz) print();
	for(int i=0;i<12;++i){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(double)tmp*dig;
		dig/=10.0;
	}
	return *this;
}
inline kout &kout::operator<(long double val){
	if(val<0.0L){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1.0L;
	long double dig=1.0L;
	while(val/dig<=-10.0L) dig*=10.0L;
	int tmp;
	while(dig>=1.0L){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(long double)tmp*dig;
		dig/=10.0L;
	}
	buf[idx]='.';
	if(++idx==siz) print();
	for(int i=0;i<16;++i){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(long double)tmp*dig;
		dig/=10.0L;
	}
	return *this;
}
inline kout &kout::operator<(const char *str){
	for(int i=0;str[i];++i){
		buf[idx]=str[i];
		if(++idx==siz) print();
	}
	return *this;
}
template<class T>
inline void kout::put(T *arr,int num,char dlm,char end){
	--num;
	for(int i=0;i<num;++i) (*this)<arr[i]<dlm;
	(*this)<arr[num]<end;
	return;
}

template<class E>
inline void edgeset<E>::open(int sizva,int sizea){
	sizv=sizva;
	size=0;
	idxf=new int[sizva];
	for(int i=0;i<sizva;++i) idxf[i]=-1;
	idxn=new int[sizea];
	for(int i=0;i<sizea;++i) idxn[i]=-1;
	dat=new E[sizea];
	return;
}
template<class E>
inline void edgeset<E>::close(void){
	sizv=size=0;
	delete[] idxf;
	delete[] idxn;
	idxf=idxn=nullptr;
	delete[] dat;
	dat=nullptr;
	return;
}
template<class E>
inline int edgeset<E>::first(int num){
	return idxf[num];
}
template<class E>
inline int edgeset<E>::next(int idx){
	return idxn[idx];
}
template<class E>
inline void edgeset<E>::add(int num,E val){
	dat[size]=val;
	idxn[size]=idxf[num];
	idxf[num]=size++;
	return;
}
template<class E>
inline E &edgeset<E>::operator[](int idx){
	return dat[idx];
}
template<class E>
inline int edgeset<E>::vsize(void){
	return sizv;
}
template<class E>
inline int edgeset<E>::esize(void){
	return size;
}
template<class E>
inline edgeset<E>::edgeset(){
	sizv=size=0;
	idxf=idxn=nullptr;
	dat=nullptr;
}
template<class E>
inline edgeset<E>::edgeset(int vertex,int siza){
	open(vertex,siza);
}