const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const arr = JSON.parse(await readline());
arr.sort((a, b) => {
if (a[0] === b[0]) {
return b[1] - a[1];
} else {
return b[0] - a[0];
}
});
let ans = 0;
const dp = new Array(arr.length).fill(1);
for (let i = 1; i < arr.length; i++) {
for (let j = 0; j < i; j++) {
if (arr[i][1] < arr[j][1]) {
dp[i] = Math.max(dp[i], dp[j] + 1);
}
}
}
console.log(Math.max(...dp));
})();