For how many rational numbers $p$ is the area of the triangle formed by the intercepts and vertex of $f(x) = -x^2+4px-p+1$ an integer?
1. **Rewrite the function in vertex form:**
   The given quadratic function is \( f(x) = -x^2 + 4px - p + 1 \). To rewrite it in vertex form, we complete the square:
   \[
   f(x) = -x^2 + 4px - p + 1 = -\left(x^2 - 4px\right) - p + 1
   \]
   \[
   = -\left(x^2 - 4px + 4p^2 - 4p^2\right) - p + 1
   \]
   \[
   = -\left((x - 2p)^2 - 4p^2\right) - p + 1
   \]
   \[
   = -(x - 2p)^2 + 4p^2 - p + 1
   \]
   So, the vertex form is:
   \[
   f(x) = -(x - 2p)^2 + 4p^2 - p + 1
   \]

2. **Determine the y-coordinate of the vertex:**
   The y-coordinate of the vertex is given by the constant term in the vertex form:
   \[
   y = 4p^2 - p + 1
   \]
   Let this be \( q \):
   \[
   q = 4p^2 - p + 1
   \]

3. **Find the roots of the quadratic function:**
   Using the quadratic formula \( x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \) for \( f(x) = -x^2 + 4px - p + 1 \):
   \[
   x = \frac{-4p \pm \sqrt{(4p)^2 - 4(-1)(-p + 1)}}{2(-1)}
   \]
   \[
   = \frac{-4p \pm \sqrt{16p^2 - 4(p - 1)}}{-2}
   \]
   \[
   = \frac{-4p \pm \sqrt{16p^2 - 4p + 4}}{-2}
   \]
   \[
   = \frac{-4p \pm \sqrt{4(4p^2 - p + 1)}}{-2}
   \]
   \[
   = \frac{-4p \pm 2\sqrt{4p^2 - p + 1}}{-2}
   \]
   \[
   = 2p \pm \sqrt{4p^2 - p + 1}
   \]
   So, the roots are \( 2p \pm \sqrt{q} \).

4. **Calculate the base of the triangle:**
   The base of the triangle is the difference between the roots:
   \[
   \text{Base} = (2p + \sqrt{q}) - (2p - \sqrt{q}) = 2\sqrt{q}
   \]

5. **Calculate the area of the triangle:**
   The area of the triangle is given by:
   \[
   \text{Area} = \frac{1}{2} \times \text{Base} \times \text{Height}
   \]
   Here, the height is the y-coordinate of the vertex, which is \( q \):
   \[
   \text{Area} = \frac{1}{2} \times 2\sqrt{q} \times q = q\sqrt{q}
   \]
   For the area to be an integer, \( q\sqrt{q} \) must be an integer. This implies \( q \) must be a perfect square.

6. **Solve for \( p \) such that \( q \) is a perfect square:**
   Let \( q = x^2 \), where \( x \) is an integer:
   \[
   4p^2 - p + 1 = x^2
   \]
   This is a quadratic equation in \( p \):
   \[
   4p^2 - p + 1 - x^2 = 0
   \]
   Using the quadratic formula for \( p \):
   \[
   p = \frac{1 \pm \sqrt{1 - 4 \cdot 4 \cdot (1 - x^2)}}{8}
   \]
   \[
   = \frac{1 \pm \sqrt{1 - 16 + 16x^2}}{8}
   \]
   \[
   = \frac{1 \pm \sqrt{16x^2 - 15}}{8}
   \]
   For \( p \) to be rational, \( 16x^2 - 15 \) must be a perfect square. Let \( 16x^2 - 15 = y^2 \):
   \[
   16x^2 - y^2 = 15
   \]
   This is a difference of squares:
   \[
   (4x - y)(4x + y) = 15
   \]

7. **Solve the factor pairs of 15:**
   The factor pairs of 15 are (1, 15) and (3, 5):
   \[
   4x - y = 1 \quad \text{and} \quad 4x + y = 15
   \]
   Adding these equations:
   \[
   8x = 16 \implies x = 2
   \]
   Subtracting these equations:
   \[
   8x = 4 \implies x = \frac{1}{2} \quad (\text{not an integer})
   \]
   Similarly, for the pair (3, 5):
   \[
   4x - y = 3 \quad \text{and} \quad 4x + y = 5
   \]
   Adding these equations:
   \[
   8x = 8 \implies x = 1
   \]
   Subtracting these equations:
   \[
   8x = 2 \implies x = \frac{1}{4} \quad (\text{not an integer})
   \]

8. **Find the rational values of \( p \):**
   For \( x = 2 \):
   \[
   p = \frac{1 \pm \sqrt{16 \cdot 2^2 - 15}}{8} = \frac{1 \pm \sqrt{64 - 15}}{8} = \frac{1 \pm \sqrt{49}}{8} = \frac{1 \pm 7}{8}
   \]
   \[
   p = 1 \quad \text{or} \quad p = -\frac{3}{4}
   \]
   For \( x = 1 \):
   \[
   p = \frac{1 \pm \sqrt{16 \cdot 1^2 - 15}}{8} = \frac{1 \pm \sqrt{16 - 15}}{8} = \frac{1 \pm 1}{8}
   \]
   \[
   p = \frac{1}{4} \quad \text{or} \quad p = 0
   \]

Thus, the rational values of \( p \) are \( -\frac{3}{4}, 0, \frac{1}{4}, 1 \).

The final answer is \( \boxed{4} \)