public void solve() throws IOException {
    int n = nextInt();
    Point[] path = new Point[n];
    for (int i = 0; i < n; i++) {
      String[] dat = nextLine().split(",");
      path[i] = new Point(Integer.parseInt(dat[0]), Integer.parseInt(dat[1]));
    }
    
    int r = nextInt();
    Road[] roads = new Road[r];
    for (int i = 0; i < r; i++) {
      String[] dat = nextLine().split(",");
      roads[i] = new Road(Integer.parseInt(dat[0]), Integer.parseInt(dat[1]), 
          Integer.parseInt(dat[2]), Integer.parseInt(dat[3]));
    }
    
    int count = 0;
    Point prev = path[0];
    for (int i = 1; i < n; i++) {
      Road rd = makeRoad(path[i], prev);
      
      for (Road road : roads) {
        if (intersect(rd, road)) {
          count++;
        }
      }
      prev = path[i];
    }
    System.out.println(count);
  }