function ff = findssmc_tax_ramsey(guess)

global  betac sigman chik epsilon_n deltac deltac_g alphac_b alphac_g omegab omegag epsilon_k epsilon_y epsilon_b epsilon_g ... 
        phi_1 phi_2 phi_3 d0 d1 d2 delta_x em_row delta_nw taubar iota_w gamma_w taub taug gamma_wg iota_wg mu_dmg
        %%gamma_w gamma_bank iota_w rho_r phi_pi phi_y rho_ab rho_ag r_ss pi_ss sigmac gamma_I gamma_k

kb=guess(1);
kg=guess(2);
nb=guess(3);
ng=guess(4);
em=guess(5);

r=1/betac;
rkb=(1/betac)+deltac-1;
rkg=(1/betac)+deltac_g-1;
n=(nb^(1+epsilon_n)+ng^(1+epsilon_n))^(1/(1+epsilon_n)); 
ab=1;
ag=1;
x=(em+em_row)/(1-delta_x);
dmg=1-exp(-mu_dmg*x);
yb = ab*(1-dmg)*(kb^alphac_b)*(nb^(1-alphac_b));
abt=1-(em/(phi_1*yb));
z=phi_2*(abt^phi_3)*yb;
tau=(phi_2*phi_3/phi_1)*(abt^(phi_3-1));
yg = ag*(1-dmg)*(kg^alphac_g)*(ng^(1-alphac_g));
y=((omegab^(1/epsilon_k))*yb^((epsilon_k-1)/epsilon_k)+(omegag^(1/epsilon_k))*yg^((epsilon_k-1)/epsilon_k))^(epsilon_k/(epsilon_k-1));
pb=(omegab*(y/yb))^(1/epsilon_k);
pg=(omegag*(y/yg))^(1/epsilon_k);

ff1=kb/nb-(alphac_b*(1-dmg)*ab*(pb-phi_1*tau*(1-abt)-phi_2*(abt^phi_3))/rkb)^(1/(1-alphac_b));                   
ff2=kg/ng-(alphac_g*(1-dmg)*ag*pg/rkg)^(1/(1-alphac_g)); 
ff3=chik*(n^(sigman-epsilon_n))*(nb^epsilon_n)-(1-alphac_b)*(yb/nb)*(pb-phi_1*tau*(1-abt)-phi_2*(abt^phi_3));
ff4=chik*(n^(sigman-epsilon_n))*(ng^epsilon_n)-(1-alphac_g)*(yg/ng)*pg;
ff5=tau-(phi_2*phi_3/phi_1)*(abt^(phi_3-1));
ff=[ff1, ff2, ff3, ff4, ff5]; 