#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 29;   const double EPS = 1e-9;   const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};   int n, m;   int main() {     cin >> n >> m;     int ans = 0;     for (int i = 0; i <= n; i++) {       int tmp = 0;       int a1 = i;       int b1 = (m - 2 * i);       if (b1 < 0) break;       int r1, r2;       r1 = n - i;       r2 = (m - 2 * i);       int a2 = (r1 / 2);       int b2 = r2 - a2;       if (b2 < 0) {         tmp = i + r2;       } else {         tmp = i + a2;       }       ans = max(ans, tmp);     }     cout << ans << endl;     return 0;   }   