syms x;a=factor(x^5-x^3+x^2-1);
C = textscan(char(regexprep(char(a),'[)*(]','_')), '%s', 'delimiter', '()_');
C = C{1};min=99;l=1;
C(any(cellfun(@isempty,C),2),:) = [];
for i=1:numel(C), if char(C{i}(1))=='^', for j=numel(C)+1:C{i}(2)-48+numel(C)-1,C{j}=strcat(C{i-1},'*1^',num2str(j));end,C{i}='1';end,end;
for i=1:numel(C), K=nchoosek(C,i);
for j=1:numel(K),
M(l,1)= (prod(sym(K(j))));
M(l,2)= (prod(sym( setdiff(C,K(j)) )));
op=length(strfind(regexprep(char(M(l,1)),'[*/^+-]','_'),'_'))+length(strfind(regexprep(char(M(l,2)),'[*/^+-]','_'),'_'));