Over Fitting (Small)

Given points labeled LOVELYZ or not, place a line so one open half-plane contains only LOVELYZ points; maximize the LOVELYZ count inside it.

Medium7GeometryBrute forceSortingMathNo attempts yetTime limit1sMemory limit512 MB

Problem

We live in the age of big data, and everyone is trying to learn machine learning and data science. Dongi studied data mining and machine learning in a hurry, and now he wants to use what he learned to design an algorithm that finds a linear classifier for a given data set.

Put simply, a linear classifier is the equation of a line that correctly classifies each data point by its two feature values (x1,x2)(x_1, x_2). Many algorithms have been developed to find the best such equation for given data automatically.

The data above can be split exactly into two groups by a linear classifier.

Look at the example above. Lines H1 and H2 are good classifiers because they completely separate the white group from the black group using the two features x1x_1 and x2x_2. H3 is not a good classifier because it cannot separate the two groups.

However, a linear classifier that separates the data this exactly does not always exist. Real data has many exceptions and errors, while a linear classifier is very simple.

Dongi collected, for each of NN people, two feature values that describe the person and the girl group that the person likes best. With these two feature values, Dongi wants to find a linear classifier that picks out the people whose favorite group is Lovelyz. The linear classifier he wants must satisfy these conditions:

  • The linear classifier splits the data into two groups, Positive and Negative, based on the feature values.
  • You may freely choose which side of the line is Positive and which side is Negative.
  • The Positive group must contain only people who answered that Lovelyz is their favorite group.
  • The fewer people in the Negative group who answered that Lovelyz is their favorite group, the better the linear classifier.

Dongi planned to bring in various algorithms so that a computer could find the best linear classifier automatically. Before that, he became curious how well the theoretically best linear classifier that satisfies the conditions above performs on his data. He needs that number to evaluate the linear classifiers his program finds.

Given the data Dongi will use to build the linear classifier, write a program that computes how many of the people whose favorite group is Lovelyz the best linear classifier satisfying the conditions above can put in the Positive group.

L is the linear classifier that puts the most white points into Positive.

Look at the example above. The white points are people who answered that Lovelyz is their favorite group, and the black points are people who answered another group. The best classifier is the one that puts the most white points into Positive, so drawing line L and making the side below it Positive and the side above it Negative gives the best linear classifier. The answer in this case is 7.

Input

The first line contains a positive integer NN (6N1006 \le N \le 100), the number of responses. Each of the next NN lines contains one person's data in the form x1 x2 NAME (1000x1,x21000-1000 \le x_1, x_2 \le 1000, and the length of NAME is between 1 and 15). x1x_1 and x2x_2 are two integers that describe the person's features. NAME is the name of the person's favorite girl group, given in uppercase letters with no spaces.

A person whose favorite group is Lovelyz always has the group name LOVELYZ. There are at least 3 people whose favorite group is Lovelyz and at least 3 people whose favorite group is not.

When each person's feature values are plotted as a point on the 2D plane, no three or more points lie on one straight line.

Output

Print on one line the number of people whose favorite group is Lovelyz that the best linear classifier can classify as Positive. If no such person can be classified as Positive, print 0.