Create the mesh

mesh <- inla.mesh.2d(
  loc.domain = st_coordinates(map)[, c("X", "Y")],
  max.edge = c(50, 100),
  offset = c(50, 100),
  cutoff = 1
)
(nmesh <- mesh$n)
## [1] 1975