Let T(U-k) be the T-ideal of the polynomial identities of the algebra of k x k upper triangular matrices over a field of characteristic zero. We give an easy algorithm which calculates the generating function of the cocharacter sequence chi(n)(U-k) = Sigma(lambda proves n) m(lambda) (U-k)chi(lambda) of the T-ideal T(U-k). Applying this algorithm we have found the explicit form of the multiplicities m(lambda)(U-k) in two cases: (i) for the "largest" partitions lambda = (lambda(1), . . . , lambda(n)) which satisfy lambda(k+1) + . . . + lambda(n) = k - 1; (ii) for the first several k and any lambda.