Problem:
Score : 400 points

Problem Statement

Given is a positive integer N. Consider repeatedly applying the operation below on N:

First, choose a positive integer z satisfying all of the conditions below:

z can be represented as z=p^e, where p is a prime number and e is a positive integer;

z divides N;

z is different from all integers chosen in previous operations.

Then, replace N with N/z.

Find the maximum number of times the operation can be applied.

Constraints

All values in input are integers.

1 \leq N \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N

Output

Print the maximum number of times the operation can be applied.

Sample Input 1

24

Sample Output 1

3

We can apply the operation three times by, for example, making the following choices:

Choose z=2 (=2^1). (Now we have N=12.)

Choose z=3 (=3^1). (Now we have N=4.)

Choose z=4 (=2^2). (Now we have N=1.)

Sample Input 2

1

Sample Output 2

0

We cannot apply the operation at all.

Sample Input 3

64

Sample Output 3

3

We can apply the operation three times by, for example, making the following choices:

Choose z=2 (=2^1). (Now we have N=32.)

Choose z=4 (=2^2). (Now we have N=8.)

Choose z=8 (=2^3). (Now we have N=1.)

Sample Input 4

1000000007

Sample Output 4

1

We can apply the operation once by, for example, making the following choice:

z=1000000007 (=1000000007^1). (Now we have N=1.)

Sample Input 5

997764507000

Sample Output 5

7

Solution in Go (1.14.1) (judge verdict: Wrong Answer)

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n := scanInt(sc)
	return n
}

func resolve(n int) int {
	if n < 2 {
		return 0
	}
	if isPrime(n) {
		return 1
	}
	terms := map[int]int{}
	max := 0
	for p := range primes(n) {
		terms[p] = numP(n, p)
		if max < terms[p] {
			max = terms[p]
		}
	}
	// initSeparationNum(max)
	initPow()
	result := 0
	for k, iN := range terms {
		if iN == 0 {
			continue
		}
		for j := 1; j <= iN; j++ {
			d := pow(k, j)
			if n%d != 0 {
				break
			}
			n /= d
			result++
		}
		// result += separationNum[iN]
	}
	return result
}

var powTable map[int]map[int]int

func initPow() {
	powTable = map[int]map[int]int{}
}

func pow(n, i int) int {
	v, ok := powTable[n]
	if ok {
		if r, ok := v[i]; ok {
			return r
		}
	} else {
		powTable[n] = map[int]int{}
	}

	if i == 1 {
		return n
	}
	if i%2 == 0 {
		r := pow(n, i/2) * pow(n, i/2)
		powTable[n][i] = r
		return r
	}
	r := pow(n, i/2) * pow(n, i/2) * n
	powTable[n][i] = r
	return r
}

func isPrime(n int) bool {
	max := int(math.Sqrt(float64(n)))
	for i := 2; i <= max+1; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

var separationNum map[int]int
var separationState map[int][]int

func initSeparationNum(n int) {
	separationNum = map[int]int{1: 1}
	separationState = map[int][]int{1: []int{1}}

	for i := 2; i <= n; i++ {
		sepNum := separationNum[i-1]
		preState := separationState[i-1]
		if preState[0] != 1 {
			state := []int{1}
			for _, v := range preState {
				state = append(state, v)
			}
			separationNum[i] = sepNum + 1
			separationState[i] = state
		} else {
			idx := -1
			for j := 1; j < len(preState); j++ {
				if preState[j]-1 != preState[j-1] {
					idx = j
					break
				}
			}
			state := []int{}
			if idx == -1 {
				for j := 0; j < len(preState)-1; j++ {
					state = append(state, preState[j])
				}
				state = append(state, preState[len(preState)-1]+1)
			} else {
				for j := 0; j < idx-1; j++ {
					state = append(state, preState[j])
				}
				state = append(state, preState[idx-1]+1)
				for j := idx; j < len(preState); j++ {
					state = append(state, preState[j])
				}
			}
			separationNum[i] = sepNum
			separationState[i] = state
		}
	}
	return
}

type intSet map[int]none

func newIntSet() intSet {
	return map[int]none{}
}

func (s intSet) add(i int) (added bool) {
	_, ok := s[i]
	added = !ok
	s[i] = mark
	return
}

func (s intSet) remove(i int) (removed bool) {
	_, removed = s[i]
	delete(s, i)
	return
}

func (s intSet) doesContain(i int) bool {
	_, ok := s[i]
	return ok
}

func (s intSet) size() int {
	return len(s)
}

func (s intSet) members() chan int {
	ch := make(chan int)
	go func() {
		defer close(ch)
		for k := range s {
			ch <- k
		}
	}()
	return ch
}

type none struct{}

var mark none

func numP(n, p int) (i int) {
	for n > 0 {
		if n%p != 0 {
			break
		}
		i++
		n = n / p
	}
	return i
}

func primes(n int) chan int {
	max := int(math.Sqrt(float64(n))) + 1
	isPrime := make([]bool, max+1)
	for i := 2; i < len(isPrime); i++ {
		isPrime[i] = true
	}

	for i := 2; i < len(isPrime); i++ {
		if !isPrime[i] {
			continue
		}
		for j := 2; j*i < len(isPrime); j++ {
			isPrime[j*i] = false
		}
	}

	ch := make(chan int)
	go func() {
		for i := 2; i < len(isPrime); i++ {
			if !isPrime[i] {
				continue
			}
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}