1. Abridged Problem Statement  
Given an integer N (1 ≤ N ≤ 10⁴), compute how many positive integers ≤ N are coprime with N (i.e. whose gcd with N is 1).  

2. Detailed Editorial  

Goal: compute φ(N), the number of integers between 1 and N inclusive that are coprime to N.  

Two main approaches:

A. Brute‐force with gcd  
- Iterate i from 1 to N.  
- Use Euclid’s algorithm to compute gcd(i, N).  
- Increment a counter whenever gcd(i, N) == 1.  
- Time complexity: O(N · log N) worst-case, which is fine for N ≤ 10⁴.

B. Euler’s totient formula (more efficient for large N)  
- Factorize N into its distinct prime factors: N = p₁^e₁ · p₂^e₂ · … · p_k^e_k.  
- Use the formula φ(N) = N · ∏_{i=1..k} (1 – 1/pᵢ).  
  - For each prime divisor pᵢ, multiply the running result by (pᵢ – 1)/pᵢ.  
- Factorization by trial division up to √N takes O(√N). Totient computation is O(number_of_primes). Overall O(√N), still trivial for N ≤ 10⁴.

Either solution runs comfortably under the given limits.

Edge case: N = 1 → answer is 1 (only number 1, and gcd(1,1)=1).

3. Provided C++ Solution with Detailed Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

// Inline helpers for max/min (not used here but commonly handy).
template<class T, class T2>
inline void chkmax(T& x, const T2& y) {
    if(x < y) x = y;
}
template<class T, class T2>
inline void chkmin(T& x, const T2& y) {
    if(x > y) x = y;
}

int n;

// Read input integer n from stdin
void read() {
    cin >> n;
}

// Main solver: count how many i in [1..n] have gcd(i,n)==1
void solve() {
    int answer = 0;               // accumulator for coprime count
    for(int i = 1; i <= n; i++) {
        // std::gcd in C++17; if gcd(i,n) == 1, they are coprime
        if (gcd(i, n) == 1) {
            answer++;
        }
    }
    // Output the final count
    cout << answer << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    read();   // read input value
    solve();  // compute and print result
    return 0;
}
```

4. Python Solution with Detailed Comments  
```python
import sys
import math

def main():
    # Read N from stdin, strip newline, convert to integer
    n = int(sys.stdin.readline().strip())

    # Approach A: brute-force gcd
    count = 0
    for i in range(1, n + 1):
        if math.gcd(i, n) == 1:
            count += 1

    # Print the result
    print(count)

if __name__ == "__main__":
    main()
```

Alternative Python: Euler’s totient via factorization  
```python
import sys

def compute_phi(n):
    result = n
    x = n
    p = 2
    # Trial divide up to sqrt(x)
    while p * p <= x:
        if x % p == 0:
            # p is a prime divisor
            while x % p == 0:
                x //= p
            # apply totient factor (1 - 1/p)
            result -= result // p
        p += 1 if p == 2 else 2  # increment p (2→3, then skip evens)
    # If remainder x > 1, it's a prime factor
    if x > 1:
        result -= result // x
    return result

def main():
    n = int(sys.stdin.readline())
    print(compute_phi(n))

if __name__ == "__main__":
    main()
```

5. Compressed Editorial  
Compute φ(N): either loop i=1..N and count gcd(i,N)==1 in O(N·logN), or factor N in O(√N) and apply φ(N) = N·∏(1–1/p). Both are efficient for N ≤ 10⁴.