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 Rust (1.42.0) (judge verdict: Accepted)

use std::collections::HashMap;

fn main() {
    let n: i64 = read();

    println!("{}", solve(n));
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn solve(n: i64) -> i32 {
    // 条件から、pはNの素因数であり、zは p^e と書けるNの約数である。
    // N = p1^e1 * p2^e2 * ... * pn^en と素因数分解できたとすると、
    // zの候補は
    //   p1, p1^2, p1^3, ..., p1^e1,
    //   p2, p2^2, p2^3, ..., p2^e2,
    //   ...
    //   pn, pn^2, pn^3, ..., pn^en,
    // となる。
    //
    // まず z = p1 とすると、Nはp1で割り切れるためそれが1回。N = N/z となる。
    // 次は z = p1 とはできないため、z = p1^2 として同様に操作する。

    prime_factors(n)
        .iter()
        .map(|(&p, &c)| {
            let mut m = n;
            let mut cnt = 0;
            for i in 1..=(c + 1) / 2 {
                let k = p.pow(i as u32);
                if m % k != 0 {
                    break;
                }
                m /= k;
                cnt += 1;
            }
            cnt
        })
        .sum()
}

fn prime_factors(n: i64) -> HashMap<i64, i32> {
    let mut pf: HashMap<i64, i32> = HashMap::new();
    if n < 2 {
        return pf;
    }

    let mut k = n;

    while k % 2 == 0 {
        let v = pf.entry(2).or_insert(0);
        *v += 1;
        k /= 2;
    }

    for i in (3..=(k as f64).sqrt() as i64).step_by(2) {
        if k == 1 {
            break;
        }

        if pf.keys().any(|p| i % p == 0) {
            continue;
        }

        while k % i == 0 {
            let v = pf.entry(i).or_insert(0);
            *v += 1;
            k /= i;
        }
    }

    if k > 1 {
        pf.insert(k, 1);
    }

    pf
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_prime_factors_1() {
        let expected: HashMap<i64, i32> = vec![(2, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(2));
    }

    #[test]
    fn test_prime_factors_2() {
        let expected: HashMap<i64, i32> = vec![(2, 1), (3, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(6));
    }

    #[test]
    fn test_prime_factors_3() {
        let expected: HashMap<i64, i32> = vec![(3, 1), (5, 2), (7, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(525));
    }

    #[test]
    fn test_prime_factors_4() {
        let expected: HashMap<i64, i32> = vec![(2, 3), (3, 1), (5, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(120));
    }

    #[test]
    fn test_solve_1() {
        assert_eq!(3, solve(24));
    }

    #[test]
    fn test_solve_2() {
        assert_eq!(0, solve(1));
    }

    #[test]
    fn test_solve_3() {
        assert_eq!(3, solve(64));
    }

    #[test]
    fn test_solve_4() {
        assert_eq!(1, solve(1000000007));
    }

    #[test]
    fn test_solve_5() {
        assert_eq!(7, solve(997764507000));
    }
}