// Arup Guha
// 9/11/2012
// Solution to 9/9/2012 UCF Individual Contest Problem: Fibonacci Sum

import java.util.*;

public class e {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		// Store fibs.
		long[] fib = new long[51];
		fib[0] = 0;
		fib[1] = 1;
		for (int i=2; i<fib.length; i++)
			fib[i] = fib[i-1] + fib[i-2];
			
		// Process each case.
		int numCases = stdin.nextInt();
		for (int i=0; i<numCases; i++) {
			int n = stdin.nextInt();
			System.out.println(solve(n, fib));
		}
		
	}
	
	public static int solve(int n, long[] fib) {
		
		// Set everything up.
		long N = (long)n;
		int count = 0;
		long sum = 0;
		int index = fib.length-1;
		
		// Run the greedy algorithm considering largest fibs first.
		while (sum != N) {
			
			// We can add this number in, so do it.
			if (fib[index] <= N - sum) {
				sum += fib[index];
				count++;
			}
			
			index--;
		}
		
		// Note: Since Fibs increase slower than 2^i, there's always a solution, so I can 
		//       count on the previous loop ending...pun intended =)
		return count;
		
	}
	
}