Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).

Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.

Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.

Input

The first line of the input contains two positive integers a1 and a2 (1 ≤ a1, a2 ≤ 100), the initial charge level of first and second joystick respectively.

Output

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.

Sample Input

Input
3 5
Output
6
Input
4 4
Output
5
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b;
scanf("%d%d",&a,&b);
int ans=;
while(a>&&b>){
if(a==&&b==) break;
if(a>=b){
a-=;
b+=;
}else{
a+=;
b-=;
}
ans++;
}
printf("%d\n",ans);
return ;
}

最新文章

  1. linux(十一)__Apache服务器
  2. [转] eclipse SVN中文件修改后图标不变黑星解决
  3. GJM: Unity3D AssetBundle 手记 [转载]
  4. 设计模式之桥接模式(Bridge)
  5. To Noob Json是什么鬼?
  6. webpack的配置及使用
  7. 高速决心linux上oracle安装垃圾问题
  8. jsp内部传参与重定向传参
  9. ubuntu配置openvpn
  10. Unity无缝循环世界实现
  11. mysql基于binlog回滚工具_flashback(python版本)
  12. 简易RPC框架-私有协议栈
  13. Uncaught TypeError: download is not a function at HTMLAnchorElement.onclick (index.html:25)
  14. React-Native(一):React Native环境搭建
  15. Python UnboundLocalError和NameError错误根源解析
  16. 转:Linux下查看tomcat占用端口
  17. ActiveMQ 消息的重新投递
  18. 基于tensorflow实现mnist手写识别 (多层神经网络)
  19. HDU 1213(并查集)
  20. kong k8s 安装 以及可视化管理界面

热门文章

  1. 【Trie】bzoj1212 [HNOI2004]L语言
  2. 【点分治】poj1741 Tree / poj2114 Boatherds / poj1987 Distance Statistics
  3. Activity组件(传递数据)
  4. 【转载】Mini6410启动过程
  5. (转)Android Eclipse 代码混淆
  6. 页面自动适应大小&amp;&amp;获取页面的大小
  7. [Android UI] Service里面启动Activity和Alertdialog
  8. 各种Lisp系语言大检阅
  9. jenkins结合docker
  10. Android App引导页这些坑你自己犯过吗?