```
class Solution(object):
def eraseOverlapIntervals(self, intervals):
intervals.sort(key=lambda x: x.end)
count = 0
for i in range(1, len(intervals)):
if intervals[i].start<intervals[i-1].end:
count += 1
intervals[i] = intervals[i-1]
return count
```