function [ys,check] = Main_steadystate(ys,exe)
global M_

%%
%% Param Values
%%
NumberOfParameters = M_.param_nbr;                            % Number of deep parameters.
for i = 1:NumberOfParameters                                  % Loop...
  paramname = deblank(M_.param_names(i,:));                   %    Get the name of parameter i. 
  eval([ paramname ' = M_.params(' int2str(i) ');']);         %    Get the value of parameter i.
end       
check = 0;
%%
%% Exchange rates
%%
% rer_H      =   1;
% rer_U      =   1/rer_H;
%%
% Solver
 guess=abs(randn)*ones(3,1);
% guess=ones(6,1);
[res1 fval]     =   fsolve(@sfile2, guess);
% while isreal(res1)==0
% guess=abs(randn)*ones(10,1);
% [res1]     =   fsolve(@sfile, guess);
% end
options = optimset('diagnostics','on', 'Display','off','FunValCheck','off','MaxFunEvals',2000, 'MaxIter', 3000,'DiffMaxChange',1,'TolFun',1e-10,'TolX',1e-10);

[res2 fval]    =   fsolve(@sfile2, res1,options);
% fval
% res2

Y_H =res2(1);
Y_U =res2(2);
% P_sc_H=res2(3);
P_sc_U=res2(3);
% Bs = res2(6);
% Bs_U = res2(7);

%%
%% Home
%%
P_sd_H = 1;
P_sc_H = 1;

rer_H = ( (1/dlt_mc_H)*(P_sc_U)^(r_c/(r_c-1)) - ((1-dlt_mc_H)/dlt_mc_H)*(P_sc_U/P_sc_H)^(r_c/(r_c-1))    )^((r_c-1)/r_c);
rer_U = 1/rer_H;

P_sm_H      =	rer_H*P_sc_H/P_sc_U;

% P_sc_H = (   (1-dlt_mc)*P_sd_H^(r_c/(r_c-1))   +   dlt_mc*P_sm_H^(r_c/(r_c-1))  )^((r_c-1)/r_c);


r_k_H = (1/betta - (1-dlt));

w_H       = (   (1    -   (1-dlt_l)*r_k_H^(r_v/(r_v-1)))/dlt_l  )^((r_v-1)/r_v);

% mc      =  ((1-dlt_oy)*lmbd_sv^(r_o/(r_o-1))   +   dlt_oy*P_so^(r_o/(r_o-1))  )^((r_o-1)/r_o);
mc_H=1;
K_H  =   (1-dlt_l)*(1/r_k_H)^(1/(1-r_v))*Y_H;
L_H  =  dlt_l*(1/ w_H)^(1/(1-r_v))*Y_H;

C_H = (chi0*(P_sc_H /w_H)*(1-L_H)^(-chi))^(-1 /sig)*(1 /(1-kappa));
C_d_H =   (1-dlt_mc_H)*(P_sc_H)^(1/(1-r_c))*C_H;

I_d_H=dlt*K_H; 

M_c_H   = dlt_mc_H*(P_sc_H/P_sm_H)^(1/(1-r_c))*C_H;
M_H = P_sm_H*( M_c_H);

%%
%%
P_sd_U = 1;
P_sm_U		=	rer_U*P_sc_U/P_sc_H;

r_k_U = (1/betta - (1-dlt));

w_U       = (   (1    -   (1-dlt_l)*r_k_U^(r_v/(r_v-1)))/dlt_l )^((r_v-1)/r_v);

% mc_U      =  ((1-dlt_oy_U)*lmbd_sv_U^(r_o/(r_o-1))   +   dlt_oy_U*P_so_U^(r_o/(r_o-1))  )^((r_o-1)/r_o);
mc_U = 1;
K_U  =   (1-dlt_l)*(1/r_k_U)^(1/(1-r_v))*Y_U;
L_U  =  dlt_l*(1/ w_U)^(1/(1-r_v))*Y_U;

C_U = (chi0*(P_sc_U /w_U)*(1-L_U)^(-chi))^(-1 /sig)*(1 /(1-kappa));
C_d_U =   (1-dlt_mc_U)*(P_sc_U)^(1/(1-r_c))*C_U;

I_d_U=dlt*K_U; 

M_c_U   = dlt_mc_U*(P_sc_U/P_sm_U)^(1/(1-r_c))*C_U;
M_U = P_sm_U*(M_c_U);

%%
%%
X_H = M_U;
X_U = M_H;

NTs_H	=	(X_H	-	M_H)/Y_H;%	+	P_so*O_x;
NTs_U	=	(X_U	-	M_U );%	-	P_so_U*O_U;


r_s_H = 1/betta;   r_s_U = 1/betta;
P_b_H = betta;     P_b_U = betta;     

phi_b_U = 1;%exp(-phi_b*Bs_U);

Bs_H = NTs_H/(1/r_s_U - 1);

Bs_U = -Bs_H;
phi_b_H = 1;%exp(-phi_b*Bs_H);
%%
%%
%%
Z_H=1;              Z_U=1;              
Z_c_H=1;            Z_c_U=1;            
Z_m_H=1;            Z_m_U=1;            
Z_i_H=1;            Z_i_U=1;            

q_c_H = ((1-kappa)*C_H)^(-sig)/P_sc_H; 
q_c_U = ((1-kappa)*C_U)^(-sig)/P_sc_U; 
q_k_H = 1;%betta*q_c_H*r_k_H/(1-betta*(1-dlt)); 
q_k_U = 1;%betta*q_c_U*r_k_U/(1-betta*(1-dlt)); 

%%
%%
%%
% 
NumberOfEndogenousVariables = M_.endo_nbr;                    % Number of endogenous variables.
ys = zeros(NumberOfEndogenousVariables,1);                    % Initialization of ys (steady state).
for i = 1:NumberOfEndogenousVariables                         % Loop...
  varname = deblank(M_.endo_names(i,:));                      %    Get the name of endogenous variable i.                     
  eval(['ys(' int2str(i) ') = ' varname ';']);                %    Get the steady state value of this variable.
end 

