package main
import (
"bufio"
"fmt"
"os"
)
func phi(n int) int {
if n == 1 {
return 1
}
res := n
x := n
for p := 2; p*p <= x; p++ {
if x%p == 0 {
for x%p == 0 {
x /= p
}
res = res / p * (p - 1)
}
}
if x > 1 {
res = res / x * (x - 1)
}
return res
}
func main() {
in := bufio.NewReader(os.Stdin)
var p int
fmt.Fscan(in, &p)
fmt.Println(phi(p - 1))
}