import java.util.*;
/**
* @version Ver 1.0
* @date 2025/6/19
* @description 书籍叠放
*/
public class Book {
/**
* 如果书 A 的长宽度都比 B 长宽大时,则允许将 B 排列放在 A 上面
* [[20,16],[15,11],[10,10],[9,10]]
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
//String input ="[[20,16],[15,11],[10,10],[9,10]]";
//[[20,16],[15,11],[10,10],[9,10]]
//[20,16],[15,11],[10,10],[9,10]
//[20,16]],[15,11]],[10,10]],[9,10]
// split
//[20,16]
// [15,11]
// [10,10]
// [9,10]
String[] arr = input.substring(1,input.length()-1).replace("],","]],").split("],");
// 将输入字符串转为数组集合
List<Integer[]> arrList = new ArrayList<>();
for (int i = 0; i < arr.length; i++) {
Integer[] ints = Arrays.stream(arr[i].replace("[", "").replace("]", "").split(",")).mapToInt(Integer::parseInt).boxed().toArray(Integer[]::new);
arrList.add(ints);
}
// 左右依次对比,降序排序 [[20,16],[15,11],[10,10],[9,10]]
arrList.sort((o1, o2) -> {
if(Objects.equals(o1[0], o2[0])){
return o2[1]-o1[1];
}
return o2[0] - o1[0];
});
// 符合要求的数组
List<Integer[]> okList = new ArrayList<>();
// 获取长宽最大的第一个数组
Integer[] firstArr = arrList.get(0);
okList.add(firstArr);
// 遍历余下的数组集合
for (int i = 1; i < arrList.size(); i++) {
// 获取下一个数组
Integer[] nextArr = arrList.get(i);
// 通过第一个数组去寻找长宽都比第一个数组小的第二个数组
if(firstArr[0] > nextArr[0] && firstArr[1] > nextArr[1] ){
okList.add(nextArr);
// 将新加入的“下一个数组”置为“待比较的第一个数组”
firstArr = nextArr;
}
}
// 输出符合要求的数组大小
System.out.println(okList.size());
}
}