#include using namespace std; int sb,sw; int main() { int n,m,a,b,i; cin>>n>>m; for (i=1;i<=n;++i) { cin>>a>>b; if (a>b) sb+=a; else sw+=b; } cout<