So it requires at most log2(logj(m)) iterations of the inner loop until the condition j < m is no longer fulfilled, thus O(log(log(m))). And if we ignore the bases, we can estimate the total complexity at O(log(n)·log(log(m))).