Hi I have a arraylist of characters where i stored my logic expression. My code count the variables in the list and my problem is when I have same variable but there is a not sign and also a parenthesis. For example: xy+zy' the number of variables should be 4 the y and y' are different.

```
public void simplify(String strexp){

 int length = strexp.length();

     //get the size and variables used in expression
    List<Character> usedVariables = new ArrayList<Character>();
    for (int i = 0; i < length; i++) {
        char c = strexp.charAt(i);
        if (Character.isLetter(c) && !usedVariables.contains(c)&&usedVariables.contains('\'')) {
            usedVariables.add(c);
        }
    }
}

```