function [FOR, BACK, FOR_BACK, VIT] = ppst(A,B,O)

Q=size(A,1);

pr=eye(Q,1);
pr2=eye(Q-2,1);

A2=A(2:(Q-1),2:(Q-1));
A2(Q-2,Q-2)=1;
B2=B(2:(Q-1),:);

[ALPHA,BETA] = f_b(A,B);
[ALPHA2,BETA2,GAMMA2] = forwards_backwards(pr2,A2,B2);

FOR_BACK=0;
FOR=0;
BACK=0;
VIT=0;

% FOR = A(2:(Q-1),Q)'* ALPHA(2:(Q-1),size(O,2));
% BACK = A(1,2:(Q-1))*(B(2:(Q-1),1).*BETA(2:(Q-1),1));
% FOR_BACK = ALPHA2(:,1)'*BETA2(:,size(O,2));

for i=1 : 1 : size(O,2)
%     FOR = FOR + ALPHA(:,i)'*B(:,i); 
%     BACK = BACK  + BETA(:,i)'*B(:,i);
%     FOR_BACK = FOR_BACK + (ALPHA(:,i).*BETA(:,i))'*B(:,i);
     %FOR_BACK = FOR_BACK + (ALPHA(:,i)'*BETA(:,i));
     FOR_BACK = FOR_BACK + (GAMMA2(:,i)'*B2(:,i));
     VIT = VIT +
end

%FOR_BACK = FOR_BACK / size(O,2);

end