import java.util.*;
import java.io.*;

public class A {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }
    int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    private void solve() throws IOException {
        int m = nextInt() - 1;
        int d = nextInt() - 1;
        int ans = 1;
        for (int k = 0; k < days[m] - 1; k++)
        {
            d = (d + 1) % 7;
            if (d == 0) ans++;
        }
        out.print(ans);

    }

    void run() throws IOException {
        // br = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        // Locale.setDefault(Locale.US);
        new A().run();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.time.Month;
import java.util.StringTokenizer;

/**
 * @author Andrei Chugunov
 */
public class A {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

    void solve() throws IOException {
        Month m = Month.of(nextInt());
        int dayOfWeek = nextInt();
        int column = 0;
        int days = m.minLength();

        int retain;
        if (dayOfWeek != 1) {
            column++;
            retain = days - (8 - dayOfWeek);
        } else {
            retain = days;
        }
        column += retain/7;
        if (retain %7 != 0) {
            column++;
        }

        out.println(column);
    }

    A() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new A();
    }

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}

//package Div2R393;

import java.util.Scanner;

public class A {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int d = scan.nextInt();
		int odd = 7 - d + 1;
		int totalDays = 0;
		if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8|| m == 10 || m == 12){
			totalDays = 31;
		} else if ( m == 2) {
			totalDays = 28;
		} else{
			totalDays = 30;
		}
		int ans = 1;
		ans += (totalDays - odd)/7;
		if((totalDays -odd) % 7 != 0) ans++;
		System.out.println(ans);
	}
}

import java.util.*;
public class Petr_and_a_calendar
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    int m = in.nextInt();
    int d = in.nextInt();
    int t = 0;
    if ( m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12  )
    {
      t = 31;
    }
    else if ( m == 4 || m == 6 || m == 9 || m == 11 )
    {
      t = 30;
    }
    else
    {
      t = 28;
    }
    t -= 8 - d;
    t = (int) Math.ceil(t/7.0);
    System.out.println(t+1);
  }
}

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int col = 5;

		if((m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12) && (d==6 || d==7))
		      col = 6;
		if((m==4 || m==6 || m==9 || m==11) && d==7)
		      col = 6;
		if(m==2 && d==1)
		      col = 4;

		System.out.println(col);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Div2_760A {

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		int m = Integer.parseInt(inputData.nextToken());
		int wD = Integer.parseInt(inputData.nextToken());

		int nD;
		if (m == 2) {
			nD = 28;
		} else if (m <= 7 && (m & 1) == 1) {
			nD = 31;
		} else if (8 <= m && (m & 1) == 0) {
			nD = 31;
		} else {
			nD = 30;
		}

		int cD = 1;
		int numC = 1;

		if (wD != 1) {
			cD += 8 - wD;
			wD = 1;
			numC++;
		}

		while (cD + 7 <= nD) {
			cD += 7;
			numC++;
		}
		System.out.println(numC);

	}

}

// package stupiddog;

import java.io.*;
import java.lang.*;
import java.util.*;

/**
 *
 * @author Huynh Sam Ha - BKU - VN - 1610852@hcmut.edu.vn
 * @author Stupid - Dog
 *
 */
public class StupidDog {

    public static void main(String[] args) throws IOException {
        inputSystem = new InputStreamReader(System.in);
        outputSystem = new OutputStreamWriter(System.out);
        //inputFile = new FileReader("D:/Java/File/inp.txt");
        //outputFile = new FileWriter("D:/Java/File/out.txt");

        inp = new BufferedReader(inputSystem);
        out = new PrintWriter(outputSystem);

        solve();

        inp.close();
        out.close();
    }

    static void solve() throws IOException {
        int a[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        int m = nextInt(); int d = nextInt();
        if (a[m] == 31) {
            if (d >= 6) out.println("6");
            else out.println("5");
        }
        else if (a[m] == 30) {
            if (d == 7) out.println("6");
            else out.println("5");
        }
        else {
            if (d == 1) out.println("4");
            else out.println("5");
        }
    }

    /* ---------------------------------------------------- */
    static BufferedReader inp;
    static PrintWriter out;
    static InputStreamReader inputSystem;
    static OutputStreamWriter outputSystem;
    static Reader inputFile;
    static Writer outputFile;
    static StringTokenizer token;

    /*NSt + TAB*/
    static String nextString() throws IOException {
        while (token == null || !token.hasMoreElements()) {
            token = new StringTokenizer(inp.readLine());
        }
        return token.nextToken();
    }

    /*NI + TAB*/
    static int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    /*NL + TAB*/
    static long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    /*NDB + TAB*/
    static double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

/**
 *
 * TAB
 * out.println(); outln
 * out.printf(""); outf
 *
 */

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String [] args){
        int month[] = new int[13];
        month[1]=31;
        month[2]=28;
        month[3]=31;
        month[4]=30;
        month[5]=31;
        month[6]=30;
        month[7]=31;
        month[8]=31;
        month[9]=30;
        month[10]=31;
        month[11]=30;
        month[12]=31;
        Scanner input = new Scanner(System.in);
        int m = input.nextInt();
        int d = input.nextInt();
        if(m==2 && d ==1) System.out.println(4);
        else
            System.out.println(((8-d)+28 < month[m]) ? 6:5);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;

public class Contest{
	static Random random;
	private static void mySort(int[] s) {
        for (int i = 0; i < s.length; ++i) {
            int j = random.nextInt(i + 1);
            int t = s[i];
            s[i] = s[j];
            s[j] = t;
        }
        Arrays.sort(s);
    }

	public static void main(String[] args) {
		random = new Random(543534151132L + System.currentTimeMillis());
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int m=in.nextInt();
        int d=in.nextInt();
        int result=0;
        switch(m) {
        	case 1 : case 3: case 5: case 7: case 8: case 10: case 12:
        			result=(d+30)/7;
        			if((d+30)%7!=0)result++;
        			break;
        	case 2 :	 result=(d+27)/7;
        			 	if((d+27)%7!=0)result++;
        			 	break;
        	default : 	result=(d+29)/7;
        				if((d+29)%7!=0)result++;
        				break;
        }
        out.println(result);
        out.close();

	}

	public static int gcd(int a, int b)
    {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
            return gcd.intValue();
    }

    public static long gcd(long a, long b)
    {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
            return gcd.longValue();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

}

import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Stream;

/**
 *
 * @author Pradyumn Agrawal coderbond007
 */
public class Main{
    public static InputStream inputStream = System.in;
    public static FastReader in = new FastReader(inputStream);
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static long mod = (long)1e9 + 7;
    public static void main(String[] args)throws java.lang.Exception
    {
        new Main().run();
        out.close();
    }
    void run() throws java.lang.Exception
    {
    	int[] a = new int[12];
        a[0] = a[2] = a[4] = a[6] = a[7] = a[9] = a[11] = 31;
        a[1] = 28;
        a[3] = a[5] = a[8] = a[10] = 30;
        int m = ni() - 1, d = ni();
        if(a[m] == 31){
            if(d == 7 || d == 6){
                out.println("6");
            } else {
                out.println("5");
            }
        } else if(a[m] == 30){
            if(d == 7) {
                out.println("6");
            } else {
                out.println("5");
            }
        } else {
            if(d == 1){
                out.println("4");
            } else {
                out.println("5");
            }
        }
    }
    private static int ni(){
        return in.nextInt();
    }
    private static long nl(){
        return in.nextLong();
    }
    private static String ns(){
        return in.nextString();
    }
    private static char nc(){
        return in.nextCharacter();
    }
    private static double nd(){
        return in.nextDouble();
    }

    private static char[] ns(int n)
    {
        char[] a = new char[n];
        for(int i=0;i<n;i++) a[i] = nc();
        return a;
    }

    private static char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i=0;i<n;i++) map[i] = ns(m);
        return map;
    }

    private static int[] na(int n)
    {
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = ni();
        return a;
    }

    private static long[] nal(int n)
    {
        long[] a = new long[n];
        for(int i=0;i<n;i++) a[i] = nl();
        return a;
    }
    //private void tr(Object... o) { if(o.length() > 0)System.out.println(Arrays.deepToString(o)); }
}

class FastReader{
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastReader(InputStream stream){
        this.stream = stream;
    }

    public int read(){
        if (numChars == -1){
            throw new InputMismatchException ();
        }
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read (buf);
            } catch (IOException e){
                throw new InputMismatchException ();
            }
            if (numChars <= 0){
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int peek(){
        if (numChars == -1){
            return -1;
        }
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read (buf);
            } catch (IOException e){
                return -1;
            }
            if (numChars <= 0){
                return -1;
            }
        }
        return buf[curChar];
    }

    public int nextInt(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-'){
            sgn = -1;
            c = read ();
        }
        int res = 0;
        do{
            if(c==','){
                c = read();
            }
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }

    public long nextLong(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-'){
            sgn = -1;
            c = read ();
        }
        long res = 0;
        do{
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }

    public String nextString(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        StringBuilder res = new StringBuilder ();
        do{
            res.appendCodePoint (c);
            c = read ();
        } while (!isSpaceChar (c));
        return res.toString ();
    }

    public boolean isSpaceChar(int c){
        if (filter != null){
            return filter.isSpaceChar (c);
        }
        return isWhitespace (c);
    }

    public static boolean isWhitespace(int c){
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0(){
        StringBuilder buf = new StringBuilder ();
        int c = read ();
        while (c != '\n' && c != -1){
            if (c != '\r'){
                buf.appendCodePoint (c);
            }
            c = read ();
        }
        return buf.toString ();
    }

    public String nextLine(){
        String s = readLine0 ();
        while (s.trim ().length () == 0)
            s = readLine0 ();
        return s;
    }

    public String nextLine(boolean ignoreEmptyLines){
        if (ignoreEmptyLines){
            return nextLine ();
        }else{
            return readLine0 ();
        }
    }

    public BigInteger nextBigInteger(){
        try{
            return new BigInteger (nextString());
        } catch (NumberFormatException e){
            throw new InputMismatchException ();
        }
    }

    public char nextCharacter(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        return (char) c;
    }

    public double nextDouble(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-'){
            sgn = -1;
            c = read ();
        }
        double res = 0;
        while (!isSpaceChar (c) && c != '.'){
            if (c == 'e' || c == 'E'){
                return res * Math.pow (10, nextInt ());
            }
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        }
        if (c == '.'){
            c = read ();
            double m = 1;
            while (!isSpaceChar (c)){
                if (c == 'e' || c == 'E'){
                    return res * Math.pow (10, nextInt ());
                }
                if (c < '0' || c > '9'){
                    throw new InputMismatchException ();
                }
                m /= 10;
                res += (c - '0') * m;
                c = read ();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted(){
        int value;
        while (isSpaceChar (value = peek ()) && value != -1)
            read ();
        return value == -1;
    }
    public SpaceCharFilter getFilter(){
        return filter;
    }

    public void setFilter(SpaceCharFilter filter){
        this.filter = filter;
    }

    public interface SpaceCharFilter{
        public boolean isSpaceChar(int ch);
    }
}

import java.io.*;
import java.util.*;
public class program
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int m=sc.nextInt();
        int d=sc.nextInt();
        if(m==2)
        {   if(d==1)
            System.out.println("4");
            else
             System.out.println("5");

        }
        else
        {   if(m==4||m==6||m==9||m==11)
               d=d-1;
            if(d==6||d==7)
            System.out.println("6");
            else
             System.out.println("5");
        }
    }
}

import java.util.*;
import static java.util.Map.entry;
public class P760A
{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    Map<Integer,Integer> month = Map.ofEntries(entry(1,31),entry(2,28),entry(3,31),entry(4,30),
                                              entry(5,31),entry(6,30),entry(7,31),entry(8,31),
                                              entry(9,30),entry(10,31),entry(11,30),entry(12,31));
    int m = in.nextInt();
    int d = in.nextInt();

    int ans = 1;
    int req = month.get(m) - (7 - d) - 1;
    ans += req/7;
    req %= 7;
    if(req != 0)
      ans += 1;
    System.out.println(ans);
  }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A760A {
        public static void main(String[] args) throws IOException {
            A760A a = new A760A();
            a.solve();
        }

        public void solve() throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            BufferedOutputStream bos = new BufferedOutputStream(new BufferedOutputStream(System.out));

            String[] input = br.readLine().split(" ");
            int m = Integer.parseInt(input[0]);
            int d = Integer.parseInt(input[1]);
            int td;

            //lane
            if ( m == 2)
                td = 28;
            else if ( m == 1 || m == 3 || m==5 ||
                    m==7 ||
                    m==8 ||
                    m==10 ||
                    m==12 )
                td = 31;
            else
                td = 30;

            bos.write(String.valueOf((td-(7-d+1) + 6) / 7 + 1).getBytes());
            bos.flush();
        }

}

import java.util.Scanner;

public class petrCalendar {

	public static void main(String[] args)

	{

		Scanner s =new Scanner(System.in);
		//System.out.println("Enter the month");
		int m=s.nextInt();
	  //System.out.println("enter the weekday");
		int d=s.nextInt();

		if(m<8)
		{
			if(m%2== 0 && m!=2)
			{
				checkdate30(d);
			}
			else if(m%2==0 && m==2)
			{
				checkfebdate(d);
			}
			else
			{
				checkdate31(d);
			}
		}
		else if(m>7 && m<=12)
		{
			if(m%2==0)
			{
				checkdate31(d);
			}

			else
			{
				checkdate30(d);
			}
		}
		//System.out.println("din");
	}

	private static void checkfebdate(int d) {
		// TODO Auto-generated method stub

		if(d==1)
		{
			System.out.println("4");
		}
		else
		{
			System.out.println("5");
		}

	}

	private static void checkdate31(int d) {
		// TODO Auto-generated method stub

		if(d>=6 && d<=7)
		{
		System.out.println("6");

		}
		else if(d<6)
		{
			System.out.println("5");
		}
	}

	private static void checkdate30(int d) {
		// TODO Auto-generated method stub
		if(d==7)
		{
			System.out.println("6");
		}
		else if(d<7 && d>0)
		{
			System.out.println("5");
		}

	}

}

import com.sun.org.apache.xpath.internal.operations.Bool;

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        File fileOut = new File("out.txt");
        InputStream inputStream = null;
        OutputStream outputStream = null;
        // try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        // try {outputStream= new FileOutputStream(fileOut);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        Integer month = in.nextInt();
        Integer day = in.nextInt();

        List<Integer> lengths = Arrays.asList(31,28,31,30,31,30,31,31,30,31,30,31);

        Integer lastDay = ((day-1) + lengths.get(month-1)-1) / 7 + 1;
        out.println(lastDay);

    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}

import java.util.Scanner;

/**
 * @author vivek
 *
 */
public class A {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		in.close();
		int[] months = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		int res = ((d - 1) + months[m - 1] - 1) / 7;
		System.out.println(res + 1);

	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int m = sc.nextInt();
            int d = sc.nextInt();
            int add = 0, j, ans = 0;
            if (m == 2) {
                if (d <= 7) {
                    ans = 7 - d;
                    add++;
                }
                for (j = 1 + ans + 7; j <= 28; j = j + 7)
                    add++;
                if (j - 7 < 28)
                    add++;
            }
            if ((m % 2 != 0 && m < 8) || m == 8 || m == 10 || m == 12) {
                if (d <= 7) {
                    ans = 7 - d;
                    add++;
                }
                for (j = 1 + ans + 7; j <= 31; j = j + 7)
                    add++;
                if (j - 7 < 31)
                    add++;
            } else if ((m % 2 == 0 && m < 7 && m != 2) || m == 9 || m == 11) {
                if (d <= 7) {
                    ans = 7 - d;
                    add++;
                }
                for (j = 1 + ans + 7; j <= 30; j = j + 7)
                    add++;
                if (j - 7 < 30)
                    add++;
            }
            out.println(add);
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @author vivek
 *
 */
public class A {

	/**
	 * @param args
	 * @throws IOException
	 */

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int m = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		br.close();

		int[] months = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		int res = (months[m - 1] + d - 1) / 7;
		if ((months[m - 1] + d - 1) % 7 != 0)
			System.out.println(res + 1);
		else
			System.out.println(res);
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m = in.nextInt(), d = in.nextInt();
            int[] thirty = new int[]{4, 6, 9, 11};
            int ans = 0;
            ans += (d == 1 ? 0 : 1);
            int days = 31;
            if (m == 2) {
                days = 28;
            }
            for (int day : thirty) {
                if (day == m) days = 30;
            }
            days -= (d == 1 ? 0 : 7 - d + 1);
            ans += (days / 7);
            days %= 7;
            ans += (days == 0 ? 0 : 1);
            out.println(ans);

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;

/**
 *
 * @author tunde
 */
public class PetrAndACalendar760A {

    public static void main(String[] args) {
        // September, April, June and November
        // Feburary - 28
        Scanner sc = new Scanner(System.in);
        int month = sc.nextInt();
        int weekDay = sc.nextInt();
        int noOfDays = 31;
        if (month == 4 || month == 6 || month == 9 || month == 11) {
            noOfDays = 30;
        } else if (month == 2) {
            noOfDays = 28; // Ignoring a leap year
        }
        int noOfWeeks = 4;
        switch (noOfDays) {
            case 31:
                if (weekDay > 5) {
                    noOfWeeks = 6;
                } else {
                    noOfWeeks = 5;
                }   break;
            case 30:
                if (weekDay > 6) {
                    noOfWeeks = 6;
                } else {
                    noOfWeeks = 5;
                }   break;
            case 28:
                if (weekDay > 1) {
                    noOfWeeks = 5;
                }
            default:
                break;
        }
        System.out.println(noOfWeeks);

    }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Created by ReaL PC on 12/6/2016.
 */
public class AAAAAA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            if (d == 6 || d == 7) {
                System.out.println("6");
            } else {
                System.out.println("5");
            }
        }
        if (m == 4 || m == 6 || m == 9 || m == 11) {
            if (d == 7) {
                System.out.println("6");
            } else {
                System.out.println("5");
            }
        }
        if (m == 2) {
            if (d == 1) {
                System.out.println("4");
            } else {
                System.out.println("5");
            }
        }

    }

}

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;

public class temp{

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		OutputWriter out = new OutputWriter(System.out);
		int n = in.readInt();
		int m = in.readInt();
		if(n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12 ){
			if(m > 5){
				System.out.println(6);
			}else{
				System.out.println(5);
			}
		}else if(n == 2){
			if(m != 1){
				System.out.println(5);
			}else{
				System.out.println(4);
			}
		}else{
			if(m > 6){
				System.out.println(6);
			}else{
				System.out.println(5);
			}
		}

		out.close();
	}

private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public long readLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int readInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuffer res = new StringBuffer();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		static boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return readString();
		}
	}

	private static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(outputStream);
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printLine(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	}
}

//package codeforces;

import java.util.Scanner;

public class Test {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in) ;
		int month = input.nextInt() ;
		int firstday = input.nextInt() - 1 ;
		int [] moonths = new int[12] ;
		moonths[0] = 31 ;
		moonths[1] = 28 ;
		moonths[2] = 31 ;
		moonths[3] = 30 ;
		moonths[4] = 31 ;
		moonths[5] = 30 ;
		moonths[6] = 31 ;
		moonths[7] = 31 ;
		moonths[8] = 30 ;
		moonths[9] = 31 ;
		moonths[10] = 30 ;
		moonths[11] = 31 ;
		int tot = firstday  + moonths[month - 1] ;
		int col = tot / 7;
		if(tot %  7 != 0) {
			col ++ ;
		}
		System.out.println(col);
		input.close();
	}

}

import java.util.*;
public class Paper1 {

	public static void main(String[] args) {
		int [] arr = {31,28,31,30,31,30,31,31,30,31,30,31};
		Scanner data = new Scanner(System.in);
		int a=data.nextInt();
		int b=data.nextInt();
		double c=((b-1)+arr[a-1]);
		double d=Math.ceil((double)(c/7));
		System.out.printf("%.0f",d);
	}

}

import java.util.Scanner;

public class CF_393A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int ans = 0;
		if (m == 2) {
			if (d == 1)
				System.out.println(4);
			else
				System.out.println(5);
		} else if (m == 4 || m == 6 || m == 9 || m == 11) {
			if (d == 7)
				System.out.println(6);
			else
				System.out.println(5);
		} else {
			if (d < 6)
				System.out.println(5);
			else
				System.out.println(6);
		}
	}
}

import java.util.*;

public class test{
	public static void main(String[] args){
		int [] month ={31,28,31,30,31,30,31,31,30,31,30,31};
		Scanner In = new Scanner(System.in);
		int a = In.nextInt();
		int b = In.nextInt();
		a=a-1;
		b=b-1;
		int ans = 1;
		int weeknum = b;
		for(int i=0;i<month[a]-1;i++){
			weeknum = (weeknum + 1) % 7;
			if(weeknum==0)
				ans=ans+1;
		}
		System.out.println(ans);
		In.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out,true);

		int m=sc.nextInt();
		int d=sc.nextInt();
		int ans=1;
		int r=f(m)-(8-d);
		ans+=(int)(Math.ceil(1.0*r/7.0));
		pw.println(ans);
		pw.flush();
		pw.close();
	}

	public static int f(int x){
		if(x==4 || x==6 || x==9 || x==11)
			return 30;
		else
			if(x==2)
				return 28;
		return 31;
	}

	static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
}

import java.util.Scanner;

public class Problem1 {

	private static final int[] monthLengths= {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int month=s.nextInt()-1;
		int day=s.nextInt();
		int columns=1;
		for (int i=0; i<monthLengths[month]; i++) {
			if (day>7) {
				day=1;
				columns++;
			}
			day++;
		}
		System.out.println(columns);
	}

}

//package codeforces;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Anuj on 1/23/2017.
 */
public class PetrAndACalendar {

    public Map<Integer, Integer> monthMap;

    public PetrAndACalendar() {
        monthMap = new HashMap<>();
        monthMap.put(1, 31);
        monthMap.put(2, 28);
        monthMap.put(3, 31);
        monthMap.put(4, 30);
        monthMap.put(5, 31);
        monthMap.put(6, 30);
        monthMap.put(7, 31);
        monthMap.put(8, 31);
        monthMap.put(9, 30);
        monthMap.put(10, 31);
        monthMap.put(11, 30);
        monthMap.put(12, 31);
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int month = Integer.valueOf(line[0]);
        int day = Integer.valueOf(line[1]);
        PetrAndACalendar pc = new PetrAndACalendar();
        int days = pc.monthMap.get(month);
        int rows = 1;
        int daysLeft = days - (7 - day) - 1;
        rows += daysLeft / 7;
        if (daysLeft % 7 != 0) {
            rows++;
        }
        System.out.println(rows);
    }
}

import java.util.Scanner;

public class Calendar {
	public final static int[] days={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, };

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=days[s.nextInt()]+s.nextInt()-1;
		if (n%7!=0) {
			System.out.println(n/7+1);
		}
		else {
			System.out.println(n/7);
		}
	}

}

import java.util.*;

public class c760A{

public static void main(String[] args){

	Scanner sc = new Scanner(System.in);
	int mon = sc.nextInt();
	int day = sc.nextInt();

if(mon==2 && day==1)System.out.println("4");

else if(mon==2)System.out.println("5");

else if(mon==4 || mon==6|| mon==9 || mon == 11)
{
	if(day<7)System.out.println("5");

	else System.out.println("6");
}

else
{
	if(day<6)System.out.println("5");

	else System.out.println("6");
}
return;
}
}

//package arhiv.c;

import java.util.Scanner;

public class Sor {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), d = sc.nextInt(), col;
        if (m == 4 || m == 6 || m == 9 || m == 11 ) {
            if (d > 6) System.out.println(6);
            else System.out.println(5);
        }
        else {
            if (m == 2) {
                if (d == 1) System.out.println(4);
                else System.out.println(5);
            }
            else {
                if (d > 5) System.out.println(6);
                else System.out.println(5);
            }
        }

    }
}

import java.util.Scanner;

public class A {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int k = 8 - m;
		int day = 31;
		int cnt = 1;
		if(n==4||n==6||n==9||n==11) day = 30;
		if(n==2) day = 28;
		day = day - k;
		cnt+= (day/7);
		if((day%7)!=0) cnt++;
		System.out.println(cnt);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author John Martin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        APetrAndACalendar solver = new APetrAndACalendar();
        solver.solve(1, in, out);
        out.close();
    }

    static class APetrAndACalendar {
        public void solve(int testNumber, InputReader c, OutputWriter w) {
            int m = c.readInt(), d = c.readInt();
            if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
                d += 31;
            } else if (m == 2) {
                d += 28;
            } else {
                d += 30;
            }
            d--;
            w.printLine((d - 1) / 7 + 1);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int month = in.nextInt();
            int day = in.nextInt();
            int total = 0;
            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
            {
                total = 31;
            } else if (month == 2)
            {
                total = 28;
            } else
            {
                total = 30;
            }
            int count = day == 1 ? 0 : 1;
            for (int i = 1; i <= total; i++)
            {
                if (day == 1)
                {
                    //System.out.println(i);
                    count++;
                }
                day++;
                if (day == 8)
                {
                    day = 1;
                }
            }
            out.println(count);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        private int[] month31 = new int[]{1, 3, 5, 7, 8, 10, 12};

        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int m = in.nextInt();
            int d = in.nextInt() - 1;

            boolean ok = false;
            for (int i = 0; i < month31.length; i++)
            {
                if (m == month31[i])
                {
                    ok = true;
                    break;
                }
            }
            int count = 0;
            int days = ok ? 31 : 30;
            days = m == 2 ? 28 : days;
            for (int i = 1; i <= days; i++)
            {
                count = (d == 0 && i > 1) ? count + 1 : count;
                d = (d + 1) % 7;
            }
            out.println(count + 1);
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 *
 */
public class TaskA {
    public static void main(String[] args) {
        InputStream inputStream;
        String str = null;
        if(str == null){
            inputStream = System.in;
        }else{
            inputStream = new ByteArrayInputStream(str.getBytes());
        }

        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solver {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] monthDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

            int month = in.nextInt();
            int firstDay = in.nextInt();

            int numDays = monthDays[month-1];

            int numColumns = 1;
            numDays -= (8-firstDay);

            numColumns += numDays/7;
            if(numDays%7 != 0){
                numColumns++;
            }

            System.out.println(numColumns);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

import java.util.Scanner;

public class A760 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int month = sc.nextInt();
		int firstDay = sc.nextInt();

		if (month == 2)
			firstDay += 27;
		else {
			if (month <= 7)
				firstDay += 29 + month % 2;
			else
				firstDay += 30 - month % 2;
		}

		System.out.println( (int) Math.ceil( (double) firstDay / 7));
	}
}

import java.util.*;
public class Main
{
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        int mes     = sc.nextInt();
        int dia     = sc.nextInt();
        int arr[]   = {31,28,31,30,31,30,31,31,30,31,30,31};
        int cola    = (arr[mes-1] - (8-dia))%7;
        System.out.println(1 + (cola>0?1:0) + (arr[mes-1] - (8-dia))/7);
    }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner In = new Scanner(System.in);
        int m = In.nextInt();
        int d = In.nextInt();
        int days;
        switch (m) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                days = 31;
                break;
            case 2:
                days = 28;
                break;
            default:
                days = 30;
        }
        days += (d - 1);
        System.out.println((int) Math.ceil(days / 7.0));
    }
}

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int mes = sc.nextInt();
        int diaIn = sc.nextInt();
        int[] anio = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int acarr = 8-diaIn;
        int cola = (anio[mes-1]-acarr)%7;
        int res = (anio[mes-1]-acarr-cola)/7;
        System.out.println(res+1+(cola==0?0:1));
    }
}

//package forfun;

import java.util.*;

public class Petrandacalendar {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		int[] month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		int dateneeded = month[m-1]-1+d;
		boolean divisible = ((dateneeded%7 == 0)? true:false);
		System.out.println((divisible)? dateneeded/7:(dateneeded/7+1));
	}
}

//package main;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class Main {

	public static int[] md = new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31,0};

	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		String[] data = reader.readLine().trim().split("\\s+");

		int m = Integer.parseInt(data[0]);
		int d = Integer.parseInt(data[1]);

		int mnc = md[m];

		int a = (7 - d)  + 1;
		int b = mnc - a;

		int ans = 1 + (b / 7) + (b % 7 == 0 ? 0 : 1);

		System.out.println(ans);

	}

}

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        String[] split = scanner.nextLine().split(" ");

        int mothnumb = Integer.parseInt(split[0]);
        int daynumb = Integer.parseInt(split[1]);

        int totalDays = daynumb;

        if (Arrays.asList(1, 3, 5, 7, 8, 10, 12).contains(mothnumb)) {
            totalDays += 31;
        }
        if (Arrays.asList(4, 6, 9, 11).contains(mothnumb)) {
            totalDays += 30;
        }
        if (Collections.singletonList(2).contains(mothnumb)) {
            totalDays += 28;
        }

        totalDays--;

        if ((totalDays / 7) * 7 == totalDays) {
            System.out.println(totalDays / 7);
        }

        else {
            System.out.println(totalDays / 7 +1);
        };

    }
}

import java.io.*;
import java.util.*;
public class C393A
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int ar[]={31,28,31,30,31,30,31,31,30,31,30,31};
        int n=sc.nextInt()-1;
        int d=sc.nextInt();
        int c=ar[n]/7;
        int e=(ar[n])%7;
        if(e!=0)
        {
            c++;
        }
        if(n==1&&d>1)
        {
            c++;
        }
        else if(ar[n]==30)
        {
            if(d>6)
            {
                c++;
            }
        }
        else
        {
            if(d>=6)
            {
                c++;
            }
        }
        out.print(c);
        out.close();
    }

    static class Reader
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    }
}

import java.util.Scanner;

public class a {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		int ar[] = {31,28,31,30,31,30,31,31,30,31,30,31};
		in.close();
		int a = (ar[m-1]+d-1)/7;
		if((ar[m-1]+d-1)%7 != 0){
			System.out.println(a+1);
		}else{
			System.out.println(a);
		}

	}

}

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int[] mth = {31,28,31,30,31,30,31,31,30,31,30,31};
		int m = in.nextInt();
		int day = in.nextInt();
		int dec = (mth[m-1]+day-1)/7;
		int ost = (mth[m-1]+day-1)%7;
		if(ost!=0){System.out.println(dec+1);}
		else{System.out.println(dec);}
		in.close();
	}
}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by Alvin on 1/24/2017.
 */

public class Codeforces_round_393_div_2_PetrAndACalendar {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int m = input.nextInt();
        int d = input.nextInt();
        int a = 0;
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            a = 31;
        } else if (m == 2) {
            a = 28;
        } else {
            a = 30;
        }
        int answer = 1;
        a -= (8 - d);
        while (a > 0) {
            a -= 7;
            answer++;
        }
        out.println(answer);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

/**
 * Created by linweiping on 17-1-23.
 */
public class Codeforces {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] days = new int[13];
        days[1] = 31;
        days[2] = 28;
        days[3] = 31;
        days[4] = 30;
        days[5] = 31;
        days[6] = 30;
        days[7] = 31;
        days[8] = 31;
        days[9] = 30;
        days[10] = 31;
        days[11] = 30;
        days[12] = 31;
        int x = in.nextInt();
        int y = in.nextInt();
        System.out.println(((days[x] + y - 1) + 6) / 7);
    }
}

import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     int m,d;

     Scanner input = new Scanner(System.in);

     m = input.nextInt();
     d = input.nextInt();

    if(m==1||m==3||m==5||m==7||m==8||m==10 || m==12){
        if(d>=1 && d<=5) System.out.println(5);
        else System.out.println(6);
    }
    else if(m==4 || m==6 || m==9 || m==11){
        if(d>=1 && d<=6) System.out.println(5);
        else System.out.println(6);
    }
    else if(m==2){
        if(d==1) System.out.println(4);
        else System.out.println(5);
    }

    }

}

import java.awt.Point;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class MainTest{
	public MainTest() {
		Vector<Integer> Month = new Vector<Integer>();
		Month.add(0);
		for(int i=1;i<=7;i++){
			if(i%2==0)
				Month.add(30);
			else
				Month.add(31);
		}
		Month.set(2,28);
		for(int i=8;i<=12;i++)
			if(i%2==1)
				Month.add(30);
			else
				Month.add(31);
		Scanner sc = new Scanner(System.in);
		int m,n ;
		m = sc.nextInt();
		n = sc.nextInt();
		int s = 1 ;
		int input = 0;
		while(s+7-n<Month.get(m)){
			input++;
			s+=7;
		}
		System.out.println(input+1);
 	}

	public static void main(String...strings){
		new MainTest();
	}
}

import java.util.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;

public class Main
{

  public static void main(String[] args)
  {
    long startTime = System.nanoTime();
    long endTime = System.nanoTime();
    int m=in.nextInt()-1;
    int d=in.nextInt();
    if(DAYS_IN_MONTH[m]>=(37-d))
    {
      out.println(6);
    }
    else if(DAYS_IN_MONTH[m]<(30-d))
    {
      out.println(4);
    }
    else
    {
      out.println(5);
    }
    err.println("Execution Time : +" + (endTime-startTime)/1000000 + " ms");
    exit(0);
  }

  static int [] DAYS_IN_MONTH={31,28,31,30,31,30,31,31,30,31,30,31};
  static class InputReader
  {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble(){
           return Double.parseDouble(next());
        }
    }

    static void exit(int a)
    {
      out.close();
      err.close();
      System.exit(a);
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static OutputStream errStream = System.err;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);
    static PrintWriter err = new PrintWriter(errStream);

}

import java.util.*;
import java.lang.*;
import java.io.*;

public class Temp {
	static int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE;
	static long lmax = Long.MAX_VALUE, lmin = Long.MIN_VALUE;
	static long mod = (long) 1e9 + 7;

	public static void main(String[] args) throws java.lang.Exception {
		// File file=new File("C:\\Users\\EagleEye\\Desktop\\input.txt");
		// File file1=new File("C:\\Users\\EagleEye\\Desktop\\output.txt");
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// int test=in.ni();
		int test = 1;
		int i = 0, j = 0;
		while (test-- > 0) {
			int arr[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
			int n = in.ni();
			int m = in.ni();
			n = arr[n] - (7 - m + 1);
			int ans = n / 7;
			if (n % 7 > 0)
				ans++;
			out.println(ans + 1);
		}
		out.close();
	}

	static class Pair {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}
	}

	static void print(int arr[], int len) {
		for (int i = 0; i < len; i++)
			System.out.print(arr[i] + " ");
		System.out.println();
	}

	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c & 15;
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c & 15;
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String ns() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public char[] ncs() {
			return ns().toCharArray();
		}

		public String nLine() {
			int c = read();
			// while (c != '\n' && c != '\r' && c != '\t' && c != -1)
			// c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (c != '\n' && c != '\r' && c != '\t' && c != -1);
			return res.toString();
		}

		public static boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

	}

}

import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Stream;

/**
 *
 * @author Pradyumn Agrawal coderbond007
 */
public class Main{
    public static InputStream inputStream = System.in;
    public static FastReader in = new FastReader(inputStream);
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static int maxval = Integer.MAX_VALUE;
    public static int minval = Integer.MIN_VALUE;
    public static void main(String[] args)throws java.lang.Exception
    {
        new Main().run();
        out.close();
    }
    void run() throws java.lang.Exception
    {
        int[] a = new int[12];
        a[0] = a[2] = a[4] = a[6] = a[7] = a[9] = a[11] = 31;
        a[1] = 28;
        a[3] = a[5] = a[8] = a[10] = 30;
        int m = ni() - 1, d = ni();
        if(a[m] == 31){
            if(d == 7 || d == 6){
                out.println("6");
            } else {
                out.println("5");
            }
        } else if(a[m] == 30){
            if(d == 7) {
                out.println("6");
            } else {
                out.println("5");
            }
        } else {
            if(d == 1){
                out.println("4");
            } else {
                out.println("5");
            }
        }
    }
    private static int ni(){
        return in.nextInt();
    }
    private static long nl(){
        return in.nextLong();
    }
    private static String ns(){
        return in.nextString();
    }
    private static char nc(){
        return in.nextCharacter();
    }
    private static double nd(){
        return in.nextDouble();
    }

    private static char[] ns(int n)
    {
        char[] a = new char[n];
        for(int i=0;i<n;i++) a[i] = nc();
        return a;
    }

    private static char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i=0;i<n;i++) map[i] = ns(m);
        return map;
    }

    private static int[] na(int n)
    {
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = ni();
        return a;
    }

    private static long[] nal(int n)
    {
        long[] a = new long[n];
        for(int i=0;i<n;i++) a[i] = nl();
        return a;
    }
    //out.println(Arrays.stream());
}

class FastReader{
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastReader(InputStream stream){
        this.stream = stream;
    }

    public int read(){
        if (numChars == -1){
            throw new InputMismatchException ();
        }
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read (buf);
            } catch (IOException e){
                throw new InputMismatchException ();
            }
            if (numChars <= 0){
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int peek(){
        if (numChars == -1){
            return -1;
        }
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read (buf);
            } catch (IOException e){
                return -1;
            }
            if (numChars <= 0){
                return -1;
            }
        }
        return buf[curChar];
    }

    public int nextInt(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-'){
            sgn = -1;
            c = read ();
        }
        int res = 0;
        do{
            if(c==','){
                c = read();
            }
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }

    public long nextLong(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-'){
            sgn = -1;
            c = read ();
        }
        long res = 0;
        do{
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }

    public String nextString(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        StringBuilder res = new StringBuilder ();
        do{
            res.appendCodePoint (c);
            c = read ();
        } while (!isSpaceChar (c));
        return res.toString ();
    }

    public boolean isSpaceChar(int c){
        if (filter != null){
            return filter.isSpaceChar (c);
        }
        return isWhitespace (c);
    }

    public static boolean isWhitespace(int c){
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0(){
        StringBuilder buf = new StringBuilder ();
        int c = read ();
        while (c != '\n' && c != -1){
            if (c != '\r'){
                buf.appendCodePoint (c);
            }
            c = read ();
        }
        return buf.toString ();
    }

    public String nextLine(){
        String s = readLine0 ();
        while (s.trim ().length () == 0)
            s = readLine0 ();
        return s;
    }

    public String nextLine(boolean ignoreEmptyLines){
        if (ignoreEmptyLines){
            return nextLine ();
        }else{
            return readLine0 ();
        }
    }

    public BigInteger nextBigInteger(){
        try{
            return new BigInteger (nextString());
        } catch (NumberFormatException e){
            throw new InputMismatchException ();
        }
    }

    public char nextCharacter(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        return (char) c;
    }

    public double nextDouble(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-'){
            sgn = -1;
            c = read ();
        }
        double res = 0;
        while (!isSpaceChar (c) && c != '.'){
            if (c == 'e' || c == 'E'){
                return res * Math.pow (10, nextInt ());
            }
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        }
        if (c == '.'){
            c = read ();
            double m = 1;
            while (!isSpaceChar (c)){
                if (c == 'e' || c == 'E'){
                    return res * Math.pow (10, nextInt ());
                }
                if (c < '0' || c > '9'){
                    throw new InputMismatchException ();
                }
                m /= 10;
                res += (c - '0') * m;
                c = read ();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted(){
        int value;
        while (isSpaceChar (value = peek ()) && value != -1)
            read ();
        return value == -1;
    }
    public SpaceCharFilter getFilter(){
        return filter;
    }

    public void setFilter(SpaceCharFilter filter){
        this.filter = filter;
    }

    public interface SpaceCharFilter{
        public boolean isSpaceChar(int ch);
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	private final static Random rnd = new Random();
	final static long INF = Long.MAX_VALUE;

	boolean checkIndex(int index, int size) {
		return (0 <= index && index < size);
	}

	class Edge {
		int to;
		long w;

		void Edge(int to, long w) {
			this.to = to;
			this.w = w;
		}
	}

	// ======================================================
	int n;
	List<Edge> graph[];
	int[] parents;

	// ======================================================
	void solve() throws IOException {
		int[] mes = new int[12];
		mes[0] = 31;
		mes[1] = 28;
		mes[2] = 31;
		mes[3] = 30;
		mes[4] = 31;
		mes[5] = 30;
		mes[6] = 31;
		mes[7] = 31;
		mes[8] = 30;
		mes[9] = 31;
		mes[10] = 30;
		mes[11] = 31;
		int m = rI() - 1;
		int d = rI();
		int ans = 1;
		mes[m] -= 7 - d + 1;
		ans += mes[m] / 7 + (mes[m] % 7 > 0 ? 1 : 0);
		out.println(ans);

	}

	// =======================================================
	// =======================================================
	void initGraph(int n) {
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<Edge>();
		}
	}

	// ---------------------------------

	// --------------------------------
	long[] dijkstra(int start) {
		long[] distances = new long[n];
		Arrays.fill(distances, INF);
		Arrays.fill(parents, -1);
		class Vertex implements Comparable<Vertex> {
			int index;
			long distance;

			Vertex(int index, long distance) {
				this.index = index;
				this.distance = distance;
			}

			public int compareTo(Vertex other) {
				return Long.compare(this.distance, other.distance);
			}
		}
		Queue<Vertex> q = new PriorityQueue<>();
		distances[start] = 0;
		q.add(new Vertex(start, distances[start]));
		while (q.size() > 0) {
			Vertex vertex = q.poll();
			if (vertex.distance > distances[vertex.index])
				continue;
			int from = vertex.index;
			long fromDistance = distances[from];
			for (Edge e : graph[from]) { // e = { to, w }
				int to = e.to;
				long fromToDistance = fromDistance + e.w;
				if (distances[to] > fromToDistance) {
					distances[to] = fromToDistance;
					parents[to] = from;
					q.add(new Vertex(to, distances[to]));
				}
			}
		}

		return distances;
	}

	int min(int... values) {
		int min = Integer.MAX_VALUE;
		for (int value : values) {
			min = Math.min(min, value);
		}
		return min;
	}

	int max(int... values) {
		int max = Integer.MIN_VALUE;
		for (int value : values) {
			max = Math.max(max, value);
		}
		return max;
	}
	// ==============================================================================
	// class DSU {
	//
	// int parent[];
	// int size;
	//
	// DSU(int size) {
	// this.size = size;
	// this.parent = new int[size];
	// for (int i = 0; i < size; i++) {
	// parent[i] = i;
	// sizes[i] = 1;
	// }
	// }
	//
	// int get(int v) {
	// int paren = parent[v];
	// if (paren == v)
	// return v;
	// return parent[v] = get(paren);
	// }
	//
	// void union(int a, int b) {
	// a = get(a);
	// b = get(b);
	// if (a != b) {
	// size--;
	// if (rnd.nextBoolean()) {
	// parent[a] = b;
	// sizes[b] += sizes[a];
	// } else {
	// parent[b] = a;
	// sizes[a] += sizes[b];
	// }
	//
	// }
	// }
	//
	// }

	public static void main(String[] args) {
		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	int maxA(int[] a) {
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > max) {
				max = a[i];

			}
		}
		return max;
	}

	int minA(int[] a) {
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < a.length; i++) {
			if (a[i] < min) {
				min = a[i];
			}
		}
		return min;
	}

	void init() throws FileNotFoundException {

		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}

		tok = new StringTokenizer("");
	}

	void run() {
		try {
			long timeStart = System.currentTimeMillis();

			init();
			solve();

			out.close();

			long timeEnd = System.currentTimeMillis();
			System.err.println("Time = " + (timeEnd - timeStart) + " COMPILED");
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	long memoryTotal, memoryFree;

	void memory() {
		memoryFree = Runtime.getRuntime().freeMemory();
		System.err.println("Memory = " + ((-memoryTotal + memoryFree) >> 10) + " KB");
	}

	String readLine() throws IOException {
		return in.readLine();
	}

	String delimiter = " ";

	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}

	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}

	void sort(int[] a) {
		Integer arr[] = new Integer[a.length];
		for (int i = 0; i < a.length; i++) {
			arr[i] = a[i];
		}
		Arrays.sort(arr);
		for (int i = 0; i < a.length; i++) {
			a[i] = arr[i];
		}
	}

}

import java.io.PrintWriter;
import java.util.*;

public class A393 {
	public static boolean flag;
	public static String color = "RBYG";
	public static StringBuffer s;
	public static int D,M,A[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	public static int ans[] = new int[color.length()];

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		M = cin.nextInt();
		D = cin.nextInt();

		int i = 1, j = D;
		for(i=1; A[M] > 0; i++) {

			for(; j<=7 && A[M] > 0; j++) {
				A[M]--;
			}
			j = 1;
		}
		out.printf("%d\n", i-1);
		cin.close();
		out.flush();
	}
}

import java.util.*;
import java.io.*;

public class main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		int p,q,r,NoC;

		int[] month = new int[13];
	    month[1]=month[3]=month[5]=month[7]=month[8]=month[10]=month[12]=31;
	    month[4]=month[6]=month[9]=month[11]=30;
	    month[2]=28;

	    p=month[m]+d-8;
	    q=p/7;
	    r=p%7;
	    if(r==0)
	    	NoC=q+1;
	    else
	    	NoC=q+2;

	    System.out.println(NoC);

    }

}

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }
    static class Solver {
        public void solve(InputReader in, PrintWriter out) {
            int m = in.nextInt();
            int d = in.nextInt();
            int temp = 0;
            int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            temp = days[m - 1] - (7 - d + 1);
            out.println(1 + temp / 7 + (temp % 7 != 0 ? 1 : 0));
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

import java.lang.reflect.Array;
import java.util.*;

public class PA {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int [] month =  {31,28,31,30,31,30,31,31,30,31,30,31};
        int d =  scanner.nextInt();
        int numDay =  month[m-1];
        int col = 1;
        if (d%7 == 1) col = 0;
        for (int i = 0 ; i < numDay ; i++){
            if (d%7 == 1) col ++;
            d++;
        }

        System.out.println(col);

    }

}

import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HashMap daysInEachMonth = new HashMap();
		daysInEachMonth.put(1,31);
		daysInEachMonth.put(2,28);
		daysInEachMonth.put(3,31);
		daysInEachMonth.put(4,30);
		daysInEachMonth.put(5,31);
		daysInEachMonth.put(6,30);
		daysInEachMonth.put(7,31);
		daysInEachMonth.put(8,31);
		daysInEachMonth.put(9,30);
		daysInEachMonth.put(10,31);
		daysInEachMonth.put(11,30);
		daysInEachMonth.put(12,31);

		int d,m,numOfDays,numOfCols;
		int firstCol;
		Scanner in = new Scanner(System.in);
		m = in.nextInt();
		d = in.nextInt();
		numOfDays = (int) daysInEachMonth.get(m);
		firstCol = d - 8 < 0 ? (d-8)*-1 : d-8;
		numOfCols = 1;
		numOfCols += (numOfDays-firstCol) / 7 ;
		numOfCols += (numOfDays-firstCol) % 7 == 0? 0 : 1;
		System.out.println(numOfCols);

	}

}

import java.util.Scanner;

public class ProplemSolving {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
            int m,d;
            m=sc.nextInt();
            d=sc.nextInt();
            if (m==2 && d!=1 )System.out.println(5);
            else if(m==2 && d==1){
                System.out.println(4);
            }else if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12){
                if(d==6 || d==7){
                    System.out.println(6);
                }else System.out.println(5);
            }else if (d==7){
                System.out.println(6);
            }else{
                System.out.println(5);
            }

    }

}

import java.util.*;
public class Calendar
{
    public static void main(String X[])
    {
        Scanner sc=new Scanner(System.in);
        int m=sc.nextInt();
        int d=sc.nextInt();
        int arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        int no_of_days=arr[m];
        int no_of_weeks=(no_of_days%7==0)?(no_of_days/7):(no_of_days/7+1);
        int remaining_days=no_of_days%7;
        if(remaining_days==0 && d>1)
            no_of_weeks+=1;
        else if(d>(7-remaining_days+1))
            no_of_weeks+=1;
        System.out.println(no_of_weeks);
    }
}

import java.util.Scanner;

/**
 * Created by vadim on 10.02.2017.
 */
public class tt1 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] days = {31, 28, 31,30,31,30,31,31,30,31,30,31};
        int m = sc.nextInt();
        int d = sc.nextInt();
        int daysCount = days[m-1];
        int res;
        if((d - 1 + daysCount)% 7 == 0)
            res = (d - 1 + daysCount) / 7;
        else
            res = (d - 1 + daysCount) / 7 + 1;
        System.out.println(res);
    }
}

import java.util.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;

public class Main
{

  public static void main(String[] args)
  {
    long startTime = System.nanoTime();
    long endTime = System.nanoTime();
    int m=in.nextInt()-1;
    int d=in.nextInt();
    if(DAYS_IN_MONTH[m]>=(37-d))
    {
      out.println(6);
    }
    else if(DAYS_IN_MONTH[m]<=(30-d))
    {
      out.println(4);
    }
    else
    {
      out.println(5);
    }
    err.println("Execution Time : +" + (endTime-startTime)/1000000 + " ms");
    exit(0);
  }

  static int [] DAYS_IN_MONTH={31,28,31,30,31,30,31,31,30,31,30,31};
  static class InputReader
  {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble(){
           return Double.parseDouble(next());
        }
    }

    static void exit(int a)
    {
      out.close();
      err.close();
      System.exit(a);
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static OutputStream errStream = System.err;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);
    static PrintWriter err = new PrintWriter(errStream);

}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

/**
 * Success is not final, failure is not fatal.
 * The courage to continue is what counts.
 * @author bodmas
 */
public class ProblemA {

    private int solve(int m, int d) {
        d--;
        int y = (m == 2 ? 28 : m == 9 || m == 4 || m == 6 || m == 11 ? 30 : 31) - 1;
        int x = (y + (d) + 6) / 7;
        return x;
    }

    public static void main(String[] args) throws IOException {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            int[] a = Stream.of(in.readLine().split(" ")).mapToInt(Integer :: parseInt).toArray();
            out.println(new ProblemA().solve(a[0], a[1]));
        }
    }
}

import java.util.*;
public class B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		int  a = in.nextInt() ;
		int b = in.nextInt() ;
		if(b >=7)
			System.out.println("6");
		else
			System.out.println("5");
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        private int[] month31 = new int[]{1, 3, 5, 6, 7, 8, 10, 12};

        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int m = in.nextInt();
            int d = in.nextInt() - 1;

            boolean ok = false;
            for (int i = 0; i < month31.length; i++)
            {
                if (m == month31[i])
                {
                    ok = true;
                    break;
                }
            }
            int count = 0;
            int days = ok ? 31 : 30;
            days = m == 2 ? 28 : days;
            for (int i = 1; i <= days; i++)
            {
                count = (d == 0 && i > 1) ? count + 1 : count;
                d = (d + 1) % 7;
            }
            out.println(count + 1);
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }
}

import java.util.Scanner;

public class ProplemSolving {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
            int m,d;
            m=sc.nextInt();
            d=sc.nextInt();

            if(m==2 && d==1){
                System.out.println(4);
            }else if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12){
                if(d==6 || d==7){
                    System.out.println(6);
                }else System.out.println(5);
            }else if (d==7){
                System.out.println(6);
            }else{
                System.out.println(5);
            }

    }

}

import java.io.*;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {
    String filename = "";

    FastScanner in;
    PrintWriter out;

    void solve() {
        int x = in.nextInt();
        int y = in.nextInt();
        int a = 30;
        if (x < 8 && x % 2 == 1 || x > 7 && x % 2 == 0) {
            a = 31;
        } else {
            if (x == 2) {
                a = 28;
            }
        }
        if(a%7==0) {
            a = (a - 7 + y) / 7+1;
        }else{
            a = (a - 7 + y) / 7+2;
        }
        out.print(a);
    }

    void run() throws IOException {
        InputStream input = System.in;
        OutputStream output = System.out;
        try {
            File f = new File(filename + ".in");
            if (f.exists() && f.canRead()) {
                input = new FileInputStream(f);
                output = new FileOutputStream(filename + ".out");
            }
        } catch (IOException e) {
        }
        in = new FastScanner(input);
        out = new PrintWriter(new BufferedOutputStream(output));
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    class FastScanner implements Closeable {
        private BufferedReader br;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream stream) throws FileNotFoundException {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String s = br.readLine();
                    if (s == null) {
                        return false;
                    }
                    tokenizer = new StringTokenizer(s);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.hasMoreTokens();
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() throws IOException {
            br.close();
        }
    }
}

// Code Author: Shrey Shah

import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;

public class Tester1{

	static double eps=(double)1e-6;
	static long mod=(int)1e9+9;
	public static void main(String args[]){
		InputReader sc = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code----------
		int m = sc.nextInt();
		int d = sc.nextInt();
		if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10|| m==12)
		{
			if(d<=4)
			out.print(5);
			else
				out.println(6);
		}
		else if(m==4||m==6||m==9||m==11)
		{
			if(d<=6)
				out.println(5);
			else
				out.println(6);
		}
		else if(m==2)
		{
			if(d==1)
				out.println(4);
			else
				out.println(5);
		}

		//----------The End----------
		out.close();
	}

	static boolean isSubSequence(String str1, String str2, int m, int n)
	{
	   int j = 0;
	   for (int i=0; i<n&&j<m; i++)
	       if (str1.charAt(j) == str2.charAt(i))
	         j++;

	   return (j==m);
	}

	static long fibo(long l) {
        if (l < 0) {
            throw new IllegalArgumentException("The fibo value cannot be negative");
        }

        if (l <= 1) return l;

        long[][] result = {{1, 0}, {0, 1}}; // identity matrix.
        long[][] fiboM = {{1, 1}, {1, 0}};

        while (l > 0) {
            if (l%2 == 1) {
                multMatrix(result, fiboM);
            }
            l = l / 2;
            multMatrix(fiboM, fiboM);
        }

        return result[1][0];
    }

    private static void multMatrix(long[][] result, long[][] fiboM) {
        long a = (result[0][0]%mod * fiboM[0][0]%mod)%mod +  (result[0][1]%mod * fiboM[1][0]%mod)%mod;
        long b = (result[0][0]%mod * fiboM[0][1]%mod)%mod + ( result[0][1]%mod * fiboM[1][1]%mod)%mod;
        long c = (result[1][0]%mod * fiboM[0][0]%mod)%mod + ( result[1][1]%mod * fiboM[0][1]%mod)%mod;
        long d = (result[1][0]%mod * fiboM[0][1]%mod)%mod +  (result[1][1]%mod * fiboM[1][1]%mod)%mod;

        result[0][0] = a;
        result[0][1] = b;
        result[1][0] = c;
        result[1][1] = d;
    }

	static int[] sieve(int n,int[] arr)
	{
		for(int i=2;i*i<=n;i++)
		{
			if(arr[i]==0)
			{
				for(int j=i*2;j<=n;j+=i)
					arr[j]=1;
			}
		}
		return arr;
	}

	static boolean isPal(String s)
	{
		for(int i=0, j=s.length()-1;i<=j;i++,j--)
		{
			if(s.charAt(i)!=s.charAt(j)) return false;
		}
		return true;
	}
	public static String rev(String s)
	{
		StringBuilder sb=new StringBuilder(s);
		sb.reverse();
		return sb.toString();
	}

	static long lcm(long a, long b)
	{
	    return a * (b / gcd(a, b));
	}

	static long gcd(long a, long b)
	{
	    while (b > 0)
	    {
	        long temp = b;
	        b = a % b; // % is remainder
	        a = temp;
	    }
	    return a;
	}
	static long modulo(long a,long b,long c) {
		long x=1;
		long y=a;
		while(b > 0){
			if(b%2 == 1){
				x=(x*y)%c;
			}
			y = (y*y)%c; // squaring the base
			b /= 2;
		}
		return  x%c;
	}
	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	static class Pair implements Comparable<Pair>{
		int x;
		int y;
		int i;
		Pair(int xx,int yy){
			x=xx;
			y=yy;
		}
		public Pair() {
			// TODO Auto-generated constructor stub
		}
		@Override
		public int compareTo(Pair o) {
			return Integer.compare(this.x, o.x);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class contst {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader (System.in));
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s);
		int m = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		int res = 0;
		switch(m){
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12: res = (d < 6)? 5 : 6;break;
		case 2: res = 5;break;
		default: res = (d < 7)? 5 : 6;
		}
		System.out.println(res);
	}

}

import java.util.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) {
      Scanner sc= new Scanner(System.in);
      int m=sc.nextInt();
      int d=sc.nextInt();
      int add=0,j,ans=0;
      if(m%2!=0||m==8){
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=31;j=j+7)
      		add++;
      	if(j-7<31&&j-1!=31)
      		add++;
      }
      else{
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=30;j=j+7)
      		add++;
      	if(j-7<30&&j-1!=30)
      		add++;
      }
      System.out.println(add);
    }
}

import java.util.Scanner;

public class PetrCalendar_CF_760A {
    public static void main(String[] args) {
        int n,m;
        Scanner sc=new Scanner(System.in);
        m=sc.nextInt();
        n=sc.nextInt();
        if (m==1){
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        }
        else if (m==2){
            if (n==1){
                System.out.println("4");
            }
            else {
                System.out.println("5");
            }
        }
        else if (m==3){
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        }
        else if (m==4){
            System.out.println("5");
        }
        else if (m==5){
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        } else if (m==6){
            System.out.println("5");
        }
        else if (m==7){
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        }
        else if (m==8){
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        }
        else if (m==9){
            System.out.println("5");
        }
        else if (m==10){
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        } else if (m==11){
            System.out.println("5");
        }
        else {
            if (n<=5){
                System.out.println("5");
            }
            else {
                System.out.println("6");
            }
        }

    }
}

import java.util.Scanner;

public class CF_393A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int ans = 0;
		if (m == 2) {
			System.out.println(5);
		} else if (m == 4 || m == 6 || m == 9 || m == 11) {
			if (d == 7)
				System.out.println(6);
			else
				System.out.println(5);
		} else {
			if (d < 6)
				System.out.println(5);
			else
				System.out.println(6);
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author John Martin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        APetrAndACalendar solver = new APetrAndACalendar();
        solver.solve(1, in, out);
        out.close();
    }

    static class APetrAndACalendar {
        public void solve(int testNumber, InputReader c, OutputWriter w) {
            int m = c.readInt(), d = c.readInt();
            if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
                d += 31;
            } else if (m == 2) {
                d += 29;
            } else {
                d += 30;
            }
            d--;
            w.printLine((d - 1) / 7 + 1);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Created by ReaL PC on 12/6/2016.
 */
public class AAAAAA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            if (d > 5) {
                System.out.println("6");
            } else System.out.println("5");
        }
        if (m == 4 || m == 6 || m == 9 || m == 11) {
            if (d > 6) {
                System.out.println("6");
            } else System.out.println("5");
        }
        if (m == 2)
            System.out.println("5");

    }

}

import java.util.Scanner;

public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int[] mo ={31,28,31,30,31,30,31,31,30,31,30,31};
		Scanner sc = new Scanner(System.in);
		int m  = sc.nextInt();
		int d = sc.nextInt();
		if(mo[m-1]==31){
			if(d==6 || d==7){
				System.out.print("5");
			}
			else{
				System.out.print("5");
			}
		}
		else if(mo[m-1]==30){
			if(d==7){
				System.out.print("6");
			}
			else{
				System.out.print("5");
			}
		}
		else if(mo[m-1]==28){
			if(d==1){
				System.out.print("4");
			}
			else{
				System.out.print("5");
			}

		}

	}
}

import java.util.Scanner;
public class problem {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
       int m,d;
       m = input.nextInt();
       d = input.nextInt();
       if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){
           if(d==6||d==7){
               System.out.println("6");
           }
           else System.out.println("5");
       }
       else if (m==4||m==6||m==9||m==11){
           if(d==7)System.out.println("6");
           else System.out.println("5");
       }
       else if(m==2){
           if(d==1)System.out.println("4");
           else if (d==2)System.out.println("5");
       }
    }
}

import java.util.Scanner;

public class petrCalendar {

	public static void main(String[] args)

	{

		Scanner s =new Scanner(System.in);
	//	System.out.println("Enter the month");
		int m=s.nextInt();
	 // System.out.println("enter the weekday");
		int d=s.nextInt();

		if(m<8)
		{
			if(m%2== 0)
			{
				checkdate30(d);
			}
			else
			{
				checkdate31(d);
			}
		}
		else if(m>8 && m<12)
		{
			if(m%2==0 && m!=2)
			{
				checkdate31(d);
			}
			else if(m%2==0 && m==2)
			{
				checkfebdate(d);
			}

			else
			{
				checkdate30(d);
			}
		}
		//System.out.println("din");
	}

	private static void checkfebdate(int d) {
		// TODO Auto-generated method stub

		if(d==7)
		{
			System.out.println("5");
		}
		else
		{
			System.out.println("6");
		}

	}

	private static void checkdate31(int d) {
		// TODO Auto-generated method stub

		if(d>=6 && d<=7)
		{
		System.out.println("6");

		}
		else if(d<6)
		{
			System.out.println("5");
		}
	}

	private static void checkdate30(int d) {
		// TODO Auto-generated method stub
		if(d==7)
		{
			System.out.println("6");
		}
		else if(d<7 && d>0)
		{
			System.out.println("5");
		}

	}

}

import java.util.*;
public class Test{
	public static Scanner s=new Scanner(System.in);
	public static int i,j;
	public static void RhN(){
		int m=s.nextInt();
		int d=s.nextInt();
		if(m==1 || m==10){
			if(d==7) System.out.println("6");
			else System.out.println("5");
		}
		else if(m==2 || m==3){
			if(d==1 || d==2) System.out.println("5");
			else System.out.println("6");
		}
		else if(m==4){
			if((d==6 || d==7)) System.out.println("5");
			else System.out.println("4");
		}
		else if(m==5) System.out.println("5");
		else if(m==6){
			if(m<4) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==7){
			if(d<6) System.out.println("5");
			else System.out.println("6");
		}
		else if(m==8){
			if(d==1) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==9){
			if(d<5) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==11){
			if(d<3) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==12){
			if(d<5) System.out.println("4");
			else System.out.println("5");
		}

	}
	public static void main(String[]args){
		Test t=new Test();
		Test.RhN();
	}
}

import java.util.Objects;
import java.util.Scanner;

public class HelloWorld
{

	public static void main(String[] args)
	{

		Scanner in = new Scanner (System.in);
		int Month= in.nextInt();
		Scanner in2 = new Scanner (System.in);
		int sDay= in.nextInt();
		sDay=8-sDay;
		double dayNum = 0;
		switch(Month){
		case 1:dayNum=31;break;
		case 3:dayNum=31;break;
		case 5:dayNum=31;break;
		case 7:dayNum=31;break;
		case 8:dayNum=31;break;
		case 10:dayNum=31;break;
		case 12:dayNum=31;break;

		case 2:dayNum=28;break;

		case 4:dayNum=30;break;
		case 6:dayNum=30;break;
		case 9:dayNum=30;break;
		case 11:dayNum=30;break;
		}
		dayNum=dayNum-sDay;
		System.out.println(dayNum);
		dayNum=Math.ceil(dayNum/7);
		System.out.println(dayNum+1);
	}

}

import java.io.*;
import java.util.*;
public class C393A
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int ar[]={31,28,31,30,31,30,31,30,31,31,30,31};
        int n=sc.nextInt()-1;
        int d=sc.nextInt();
        int c=ar[n]/7;
        int e=(ar[n])%7;
        if(e!=0)
        {
            c++;
        }
        if(n==1)
        {
            c++;
        }
        else if(ar[n]==30)
        {
            if(d>6)
            {
                c++;
            }
        }
        else
        {
            if(ar[n]==31)
            {
                if(d>5)
                {
                    c++;
                }
            }
        }
        out.print(c);
        out.close();
    }

    static class Reader
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Created by ReaL PC on 12/6/2016.
 */
public class AAAAAA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            if (d == 6 || d == 7) {
                System.out.println("6");
            } else {
                System.out.println("5");
            }
        }
        if (m == 4 || m == 6 || m == 9 || m == 11) {
            if (d == 7) {
                System.out.println("6");
            } else {
                System.out.println("5");
            }
        }
        if (m == 2) {
            System.out.println("5");
        }

    }

}

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int mes = sc.nextInt();
        int diaIn = sc.nextInt();
        int acarr = 8-diaIn;
        int cola = (mes*31-acarr)%7;
        int res = (mes*31-acarr-cola)/7;
        System.out.println((res+1+(cola==0?0:1))/mes + (((res+1+(cola==0?0:1))% mes ==0)?0: 1)  );
    }
}

import java.util.Scanner;

public class petrCalendar {

	public static void main(String[] args)

	{

		Scanner s =new Scanner(System.in);
		//System.out.println("Enter the month");
		int m=s.nextInt();
	  //System.out.println("enter the weekday");
		int d=s.nextInt();

		if(m<8)
		{
			if(m%2== 0 && m!=2)
			{
				checkdate30(d);
			}
			else if(m%2==0 && m==2)
			{
				checkfebdate(d);
			}
			else
			{
				checkdate31(d);
			}
		}
		else if(m>7 && m<12)
		{
			if(m%2==0)
			{
				checkdate31(d);
			}

			else
			{
				checkdate30(d);
			}
		}
		//System.out.println("din");
	}

	private static void checkfebdate(int d) {
		// TODO Auto-generated method stub

		if(d==7)
		{
			System.out.println("5");
		}
		else
		{
			System.out.println("4");
		}

	}

	private static void checkdate31(int d) {
		// TODO Auto-generated method stub

		if(d>=6 && d<=7)
		{
		System.out.println("6");

		}
		else if(d<6)
		{
			System.out.println("5");
		}
	}

	private static void checkdate30(int d) {
		// TODO Auto-generated method stub
		if(d==7)
		{
			System.out.println("6");
		}
		else if(d<7 && d>0)
		{
			System.out.println("5");
		}

	}

}

//package Div2R393;

import java.util.Scanner;

public class A {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int d = scan.nextInt();
		int odd = 7 - d + 1;
		int totalDays = 0;
		if(m == 1 || m == 5 || m == 7 || m == 8|| m == 10 || m == 12){
			totalDays = 31;
		} else if ( m == 2) {
			totalDays = 29;
		} else{
			totalDays = 30;
		}
		int ans = 1;
		ans += (totalDays - odd)/7;
		if((totalDays -odd) % 7 != 0) ans++;
		System.out.println(ans);
	}
}

import java.io.*;
import java.util.*;
public class C393A
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int ar[]={31,28,31,30,31,30,31,30,31,31,30,31};
        int n=sc.nextInt()-1;
        int d=sc.nextInt();
        int c=ar[n]/7;
        int e=(ar[n])%7;
        if(e!=0)
        {
            c++;
        }
        if(n==1&&d>1)
        {
            c++;
        }
        else if(ar[n]==30)
        {
            if(d>6)
            {
                c++;
            }
        }
        else
        {
            if(ar[n]==31)
            {
                if(d>5)
                {
                    c++;
                }
            }
        }
        out.print(c);
        out.close();
    }

    static class Reader
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    }
}

import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HashMap daysInEachMonth = new HashMap();
		daysInEachMonth.put(1,31);
		daysInEachMonth.put(2,28);
		daysInEachMonth.put(3,31);
		daysInEachMonth.put(4,30);
		daysInEachMonth.put(5,31);
		daysInEachMonth.put(6,30);
		daysInEachMonth.put(7,31);
		daysInEachMonth.put(8,31);
		daysInEachMonth.put(9,30);
		daysInEachMonth.put(10,31);
		daysInEachMonth.put(11,30);
		daysInEachMonth.put(12,31);

		int d,m,numOfDays,numOfCols;
		int firstCol;
		Scanner in = new Scanner(System.in);
		m = in.nextInt();
		d = in.nextInt();
		numOfDays = (int) daysInEachMonth.get(m);
		firstCol = (d % 7) + 1;
		numOfCols = 1;
		numOfCols +=(numOfDays-firstCol) / 7 ;
		numOfCols += numOfDays % 7 == 0? 0 : 1;
		System.out.println(numOfCols);
		System.out.println(numOfDays);

	}

}

import java.util.Scanner;

public class Contest {

	public static void main(String[] args) {

		Scanner in = new Scanner( System.in );

		int n = in.nextInt();
		int d = in.nextInt();
		if( d<7)
			System.out.println( 5 );
		else
			System.out.println( 6 );

		in.close();
	}

}

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int[] mth = {31,28,31,30,31,30,31,31,30,31,30,31};
		int m = in.nextInt();
		int day = in.nextInt();
		int ost = mth[m-1]%7;
		if(day+ost<=8){System.out.println(5);}
		else{System.out.println(6);}
		in.close();
	}
}

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int mod = m%7;
		int col = 5;

		if(mod==3 && d==6 || d==7)
		      col = 6;
		if(mod==2 && d==7)
		      col = 6;
		if(mod==0 && d!=1)
		      col = 6;

		System.out.println(col);
	}
}

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 *
 */
public class TaskA {
    public static void main(String[] args) {
        InputStream inputStream;
        String str = "11 6";
        if(str == null){
            inputStream = System.in;
        }else{
            inputStream = new ByteArrayInputStream(str.getBytes());
        }

        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solver {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] monthDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

            int month = in.nextInt();
            int firstDay = in.nextInt();

            int numDays = monthDays[month-1];

            int numColumns = 1;
            numDays -= (8-firstDay);

            numColumns += numDays/7;
            if(numDays%7 != 0){
                numColumns++;
            }

            System.out.println(numColumns);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

//package codeforces;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Anuj on 1/23/2017.
 */
public class PetrAndACalendar {

    public Map<Integer, Integer> monthMap;

    public PetrAndACalendar() {
        monthMap = new HashMap<>();
        monthMap.put(1, 31);
        monthMap.put(2, 28);
        monthMap.put(3, 31);
        monthMap.put(4, 30);
        monthMap.put(5, 31);
        monthMap.put(6, 30);
        monthMap.put(7, 31);
        monthMap.put(8, 31);
        monthMap.put(9, 30);
        monthMap.put(10, 31);
        monthMap.put(11, 30);
        monthMap.put(12, 31);
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int month = Integer.valueOf(line[0]);
        int day = Integer.valueOf(line[1]);
        PetrAndACalendar pc = new PetrAndACalendar();
        int days = pc.monthMap.get(month);
        int rows = 1;
        int daysLeft = days - (7 - day) + 1;
        rows += daysLeft / 7;
        if (daysLeft % 7 != 0) {
            rows++;
        }
        System.out.println(rows);
    }
}

import static java.lang.Math.*;
import static java.util.Arrays.* ;

import java.util.*;
import java.io.*;

public class D
{

    void main() throws Exception
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int m = sc.nextInt() ;
        int d = sc.nextInt() ;
        int cnt = 1 ;
        if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
        {
            for(int i = 1 ; i <= 31 ; i++)
            {
                d ++ ;
                if(d == 8)
                {
                    d = 1;
                    cnt ++ ;
                }
            }
        }
        else if(m == 2)
        {
            for(int i = 1 ; i <= 28 ; i++)
            {
                d ++ ;
                if(d == 8)
                {
                    d = 1;
                    cnt ++ ;
                }
            }

        }
        else
        {
            for(int i = 1 ; i <= 30 ; i++)
            {
                d ++ ;
                if(d == 8)
                {
                    d = 1;
                    cnt ++ ;
                }
            }

        }
        out.println(cnt);
        out.flush();
        out.close();
    }
    class Scanner
    {
        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream in)
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws Exception
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        String nextLine() throws Exception
        {
            return br.readLine() ;
        }
        int nextInt() throws Exception { return Integer.parseInt(next()); }

        long nextLong() throws Exception { return Long.parseLong(next()); }

        double nextDouble() throws Exception { return Double.parseDouble(next());}
    }

    public static void main (String [] args) throws Exception {(new D()).main();}

}

import java.util.*;

public class Exam {

    private static final Scanner INPUT = new Scanner(System.in);

    public static void main(String[] args) {
        int month = INPUT.nextInt();
        int day = INPUT.nextInt();
        int week = 0;
        switch(month(month)) {
            case 31:
                if(day > 5) {
                    week = 6;
                } else
                    week = (31 + day) / 7 + 1;
                break;
            case 30:
                    week = (30 + day) / 7;
                    break;
            case 28:
                week = (28 + day) / 7;
                break;

        }
        System.out.printf("%d", week);

    }

    private static int month(int month) {
        int days;
        if(month <= 7) {
            if(month % 2 == 1) {
                days = 31;
            } else {
                if(month != 2) {
                    days = 30;
                } else
                    days = 28;
            }
        } else {
            if(month % 2 == 0) {
                days = 31;
            } else
                days = 30;
        }
        return days;
    }

}

import java.util.Scanner;
public class petr
{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
        int m= s.nextInt();
        int d= s.nextInt();
        int n, a=0;
        n=28;
        if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
        n=31;
        else
        n=30;
        if(n==30)
        {
            if(d==7)
            {
                a=6;
            }
            else
            {
                a=5;
            }
        }
        else if(n==31)
        {
            if(d>=6)
            {
                a=6;
            }
            else
            {
                a=5;
            }
        }
        else if(n==28)
        {
            if(d==1)
            {
                a=4;
            }
            else
            {
                a=5;
            }
        }
        System.out.println(a);
    }
}

import java.util.Scanner;

public class CF_393A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int ans = 0;
		if(m == 4 || m == 6 || m == 9 || m == 11 || m == 2) {
			if(d == 7)
				System.out.println(6);
			else
				System.out.println(5);
		} else {
			if(d < 6)
				System.out.println(5);
			else
				System.out.println(6);
		}
	}
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.regex.*;
public class Myclass {
	public static boolean visited[]=new boolean[100001];
	static ArrayList [] a=new ArrayList[100001];
	static long level[]=new long[100001];
	static Queue<Integer>pq=new LinkedList<>();
	public static void bfs(int x)
	{
		pq.add(x);
		level[x]=0;
		while(!pq.isEmpty())
		{
			int y=pq.poll();
			visited[y]=true;
			for(int i=0;i<a[y].size();i++)
			{
				if(visited[(int) a[y].get(i)]==false)
				{
					pq.add((int) a[y].get(i));
					level[(int) a[y].get(i)]=level[y]+1;
				}
			}
		}
	}

	public static void main(String[] args)
	{
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int a[]= {31,29,31,30,31,30,31,31,30,31,30,31};
		int m=in.nextInt();
		int d=in.nextInt();
		int days=a[m-1];
		days=days-(8-d);
		pw.println(1+(int)Math.ceil((double)days/7));
		pw.flush();
		pw.close();

	}

		static class InputReader
		{
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}
		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}
		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}

		public static HashSet<Integer> primeFactorization(int n)
		{
			HashSet<Integer> a =new HashSet<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    if (n%2 == 0 || n%3 == 0)
		    	return false;

		    for (int i=5; i*i<=n; i=i+6)
		    {
		        if (n%i == 0 || n%(i+2) == 0)
		           return false;
		    }

		    return true;
		}

		 public static long[] shuffle(long[] a, Random gen){
		        for(int i = 0, n = a.length;i < n;i++){
		            int ind = gen.nextInt(n-i)+i;
		            long d = a[i];
		            a[i] = a[ind];
		            a[ind] = d;
		        }
		        return a;
		    }
		static class pair implements Comparable<pair>
		{
			Long x;
			Long y;
			pair(long l,long m)
			{
				this.x=l;
				this.y=m;
			}

		public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}
}

import java.io.*;
import java.util.*;

public class Main {

    static StringBuilder data = new StringBuilder();
    final static FastReader in = new FastReader();

    public static void main(String[] args) {
        int m = in.nextInt(), d = in.nextInt();
        int answ = 0;
        for (int i = 1; i <= m; i++) {
            if (i == 2) {
                if (d == 1) {
                    answ = 4;
                } else {
                    answ = 5;
                }
            } else if (i % 2 != 0 || i == 8) {
                if (d <= 5) {
                    answ = 5;
                } else {
                    answ = 6;
                }
                d = ((d + 3) % 7==0)?7:(d + 3) % 7;
            } else {
                if (d <= 6) {
                    answ = 5;
                } else {
                    answ = 6;
                }
                d = ((d + 2) % 7==0)?7:(d + 2) % 7;

            }

        }
        System.out.println(answ);
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        float nextFloat() {
            return Float.parseFloat(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.*;
public class Test{
	public static Scanner s=new Scanner(System.in);
	public static int i,j;
	public static void RhN(){
		int m=s.nextInt();
		int d=s.nextInt();
		if(m==1 || m==10){
			if(d==7) System.out.println("6");
			else System.out.println("5");
		}
		else if(m==2 || m==3){
			if(d==1 || d==2) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==4){
			if((d==6 || d==7)) System.out.println("5");
			else System.out.println("4");
		}
		else if(m==5) System.out.println("5");
		else if(m==6){
			if(d<4) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==7){
			if(d<6) System.out.println("5");
			else System.out.println("6");
		}
		else if(m==8){
			if(d==1) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==9){
			if(d<5) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==11){
			if(d<3) System.out.println("4");
			else System.out.println("5");
		}
		else if(m==12){
			if(d<5) System.out.println("4");
			else System.out.println("5");
		}

	}
	public static void main(String[]args){
		Test t=new Test();
		Test.RhN();
	}
}

import java.util.Scanner;

public class PetrAndCalender {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m=scan.nextInt();
		int d=scan.nextInt();
		if(m%2!=0)
		{
			int a=((d-1)+30-1)/7+1;
			System.out.println(a);
		}
		else
		{
			int a=((d-1)+31-1)/7+1;
			System.out.println(a);
		}
	}
}

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class A {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		if(n<7){
			int k = 7 - m + 1;
			int day = 31 - k;
			int cnt = 1;
			cnt+= (day/7);
			if((day%7)!=0) cnt++;
			System.out.println(cnt);
		}else if(n<12){
			int k = 7 - m + 1 ;
			int day = 30 - k;
			int cnt = 1;
			cnt+= (day/7);
			if((day%7)!=0) cnt++;
			System.out.println(cnt);
		}else{
			int k = 7 - m + 1 ;
			int day = 29 - k;
			int cnt = 1;
			cnt+= (day/7);
			if((day%7)!=0) cnt++;
			System.out.println(cnt);
		}
	}
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
        Scanner read = new Scanner(System.in);
       int a=read.nextInt();
       int b=read.nextInt();
       if (a==2){
           System.out.println(5);
       }
       else if (a==1 || a==3 || a==1 || a==5 || a==7 || a==8 || a==10 || a==12){
           if (b>5){
               System.out.println(6);
           }else {
               System.out.println(5);
           }
       }else {
           if (b>6){
               System.out.println(6);
           }else {
               System.out.println(5);
           }
       }
    }
}

import java.util.Scanner;

/**
 * @author vivek
 *
 */
public class Solution {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		in.close();
		int c = 7 - d;
		if (m == 2) {
			int month = 28 - c;
			int res = month / 7;
			if (c < (month % 7)) {
				res += 2;
			} else {
				res += 1;
			}
			System.out.println(res);
		} else if (m == 4 || m == 6 || m == 9 || m == 11) {
			int month = 30 - c;
			int res = month / 7;
			if (c < (month % 7)) {
				res += 2;
			} else {
				res += 1;
			}
			System.out.println(res);
		} else {
			int month = 31;
			int res = month / 7;
			if (c < (month % 7)) {
				res += 2;
			} else {
				res += 1;
			}
			System.out.println(res);
		}
	}

}

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class A {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		if(n<7){
			int cnt = 0 ,seen = 0;
			for(int i = 0 ; i < 31 ; i++){
				if(m<=7){
					m++;
					seen = 1;
					if(m==8){seen = 0; m = 1;cnt++;}
				}
			}
			if(seen == 1) cnt++;
			System.out.println(cnt);
		}else if(n<12){
			int cnt = 0 ,seen = 0;
			for(int i = 0 ; i < 30 ; i++){
				if(m<=7){
					m++;
					seen = 1;
					if(m==8){seen = 0; m = 1;cnt++;}
				}
			}
			if(seen == 1) cnt++;
			System.out.println(cnt);
		}else{
			int cnt = 0 ,seen = 0;
			for(int i = 0 ; i < 29 ; i++){
				if(m<=7){
					m++;
					seen = 1;
					if(m==8){seen = 0; m = 1;cnt++;}
				}
			}
			if(seen == 1) cnt++;
			System.out.println(cnt);
		}
	}
}

import java.util.Scanner;

public class Contest {

	public static void main(String[] args) {

		Scanner in = new Scanner( System.in );

		int n = in.nextInt();
		int d = in.nextInt();
		if( d<7)
			System.out.println( 5 );
		else
			System.out.println( 6 );

		in.close();
	}

}

import java.io.*;
import java.util.*;

public class Main {

    static StringBuilder data = new StringBuilder();
    final static FastReader in = new FastReader();

    public static void main(String[] args) {
        int m = in.nextInt(), d = in.nextInt();
        int answ = 0;
        for (int i = 1; i <= m; i++) {
            if (i == 2) {
                if (d == 1) {
                    answ = 4;
                } else {
                    answ = 5;
                }
            } else if (i % 2 != 0 || i == 8) {
                if (d <= 5) {
                    answ = 5;
                } else {
                    answ = 6;
                }
                d = (d + 3) % 7==0?((d + 3) % 7)+7:(d + 3) % 7;
            } else {
                if (d <= 6) {
                    answ = 5;
                } else {
                    answ = 6;
                }
                d = (d + 2) % 7==0?((d + 2) % 7)+7:(d + 2) % 7;

            }

        }
        System.out.println(answ);
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        float nextFloat() {
            return Float.parseFloat(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.Scanner;

public class Contest {

	public static void main(String[] args) {

		Scanner in = new Scanner( System.in );

		int n = in.nextInt();
		int d = in.nextInt();

		if( n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12 )
		{
			if( d<6 )
				System.out.println( 5 );
			else
				System.out.println( 6 );
		}
		else if( n == 2 ){
			System.out.println( 5 );
		}
		else{

			if( d<7 )
				System.out.println( 5 );
			else
				System.out.println( 6 );
		}

		in.close();
	}

}

import java.util.Scanner;

public class a {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		int ar[] = {31,28,31,30,31,30,31,31,30,31,30,31};
		in.close();
		int a = (ar[m-1]+d)/7;
		if((ar[m-1]+d-1)%7 != 0){
			System.out.println(a+1);
		}else{
			System.out.println(a);
		}

	}

}

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class A {
	public static void main(String[] args) throws FileNotFoundException {
		Scanner in = new Scanner(System.in);

		int m = in.nextInt();
		int d = in.nextInt();

		int md = 0;
		if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
			md = 31;
		else if (m == 2)
			md = 28;
		else
			md = 30;

		d = d - 1;
		System.out.println((d + md) / 6);

		in.close();
	}
}

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int mod = m%7;
		int col = 5;

		if(mod==3 && d==6 || d==7)
		      col = 6;
		if(mod==2 && d==7)
		      col = 6;
		if(mod==0 && d!=1)
		      col = 6;

		System.out.println(col);
	}
}

import java.util.*;

public class Exam {

    private static final Scanner INPUT = new Scanner(System.in);

    public static void main(String[] args) {
        int month = INPUT.nextInt();
        int day = INPUT.nextInt();
        int week = 0;
        switch(month(month)) {
            case 31:
                if(day > 5) {
                    week = 6;
                } else
                    week = (31 + day) / 7 + 1;
                break;
            case 30:
                    week = (30 + day) / 7;
                    break;
            case 28:
                week = (28 + day) / 7;
                break;

        }
        System.out.printf("%d", week);

    }

    private static int month(int month) {
        int days;
        if(month <= 7) {
            if(month % 2 == 1) {
                days = 31;
            } else {
                if(month != 2) {
                    days = 30;
                } else
                    days = 28;
            }
        } else {
            if(month % 2 == 0) {
                days = 31;
            } else
                days = 30;
        }
        return days;
    }

}

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
    	Scanner scan = new Scanner(System.in);
    	int m = scan.nextInt();
    	int d = scan.nextInt();
    	Calendar c = Calendar.getInstance();
    	c.clear();
    	c.set(2017, m-1,1);
    	int days=c.getActualMaximum(Calendar.DAY_OF_MONTH);
    	if(days==30){
    		if(d<=6)
    			System.out.println(5);
    		else
    			System.out.println(6);
    	}
    	else if(days==31){
    		if(d<=5)
    			System.out.println(5);
    		else
    			System.out.println(6);
    	}
    	else{
    		if(d<=2)
    			System.out.println(5);
    		else
    			System.out.println(4);
    	}
    }
}

import java.util.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) {
      Scanner sc= new Scanner(System.in);
      int m=sc.nextInt();
      int d=sc.nextInt();
      int add=0,j,ans=0;
      if(m%2!=0||m==8){
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=31;j=j+7)
      		add++;
      	if(j-7<31)
      		add++;
      }
      else{
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=30;j=j+7)
      		add++;
      	if(j-7<30)
      		add++;
      }
      System.out.println(add);
    }
}

// package stupiddog;

import java.io.*;
import java.lang.*;
import java.util.*;

/**
 *
 * @author Huynh Sam Ha - BKU - VN - 1610852@hcmut.edu.vn
 * @author Stupid - Dog
 *
 */
public class StupidDog {

    public static void main(String[] args) throws IOException {
        inputSystem = new InputStreamReader(System.in);
        outputSystem = new OutputStreamWriter(System.out);
        //inputFile = new FileReader("D:/Java/File/inp.txt");
        //outputFile = new FileWriter("D:/Java/File/out.txt");

        inp = new BufferedReader(inputSystem);
        out = new PrintWriter(outputSystem);

        solve();

        inp.close();
        out.close();
    }

    static void solve() throws IOException {
        int a[] = {0,31,28,31,30,31,31,30,31,30,31,30,31};
        int m = nextInt(); int d = nextInt();
        if (a[m] == 31) {
            if (d >= 6) out.println("6");
            else out.println("5");
        }
        else if (a[m] == 30) {
            if (d == 7) out.println("6");
            else out.println("5");
        }
        else {
            if (d == 1) out.println("4");
            else out.println("5");
        }
    }

    /* ---------------------------------------------------- */
    static BufferedReader inp;
    static PrintWriter out;
    static InputStreamReader inputSystem;
    static OutputStreamWriter outputSystem;
    static Reader inputFile;
    static Writer outputFile;
    static StringTokenizer token;

    /*NSt + TAB*/
    static String nextString() throws IOException {
        while (token == null || !token.hasMoreElements()) {
            token = new StringTokenizer(inp.readLine());
        }
        return token.nextToken();
    }

    /*NI + TAB*/
    static int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    /*NL + TAB*/
    static long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    /*NDB + TAB*/
    static double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

/**
 *
 * TAB
 * out.println(); outln
 * out.printf(""); outf
 *
 */

import java.util.Scanner;

public class CF_393A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();

		int ans = 0;
		if (m == 2) {
			System.out.println(5);
		} else if (m == 4 || m == 6 || m == 9 || m == 11) {
			if (d == 7)
				System.out.println(6);
			else
				System.out.println(5);
		} else {
			if (d < 6)
				System.out.println(5);
			else
				System.out.println(6);
		}
	}
}

import java.util.*;
public class Solution{
       public static void main(String args[])
       {
             Scanner sc = new Scanner(System.in);
	       int m = sc.nextInt();
	       int d = sc.nextInt();
	       int arr[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	       int matrix[][] = new int[7][6];
	      // matrix[d-1][0] = 1;
	      int count = 0;
	       for(int i = d-1;i<7;i++)
	       {
	              matrix[i][0] = 1;
	              count++;
	       }

	       for(int i=1;i<6;i++)
	       {

       	      for(int j=0;j<7;j++)
       	      {
       	              if(count!=arr[m-1])
       	               {
              	              matrix[j][i] = 1;
              	              count ++;
       	               }
       	      }
	       }

	      // System.out.println(count);
	      // for(int i=0;i<7;i++)
	      // {
	      //        for(int j=0;j<6;j++)
	      //        {
	      //               System.out.print(matrix[i][j] + " ");

	      //        }
	      //         System.out.println("");
	      // }

	       int columns = 6;
	       for(int i =5;i>2;i--)
	       {
	              if(matrix[0][i] == 0)
	              {
	                     columns--;
	              }
	       }
	       System.out.print(columns);

       }
}

import java.util.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) {
      Scanner sc= new Scanner(System.in);
      int m=sc.nextInt();
      int d=sc.nextInt();
      int add=0,j,ans=0;
      if(m%2!=0||m==8){
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=31;j=j+7)
      		add++;
      	if(j-7<31)
      		add++;
      }
      else{
      	if(d<7){
      		d=7;
      		add++;
      	}
      	for(j=2+ans+7;j<=30;j=j+7)
      		add++;
      	if(j-7<30)
      		add++;
      }
      System.out.println(add);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out,true);

		int m=sc.nextInt();
		int d=sc.nextInt();
		int ans=1;
		int r=f(m)-(8-d);
		ans+=(int)(Math.ceil(1.0*r/7.0));
		pw.println(ans);
		pw.flush();
		pw.close();
	}

	public static int f(int x){
		if(x==4 || x==7 || x==9 || x==11)
			return 30;
		else
			if(x==2)
				return 28;
		return 31;
	}

	static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Created by ReaL PC on 12/6/2016.
 */
public class AAAAAA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            if (d == 6 || d == 7) {
                System.out.println("6");
            } else {
                System.out.println("5");
            }
        }
        if (m == 4 || m == 6 || m == 9 || m == 11) {
            if (d == 7) {
                System.out.println("6");
            } else {
                System.out.println("5");
            }
        }
        if (m == 2) {
            System.out.println("5");
        }

    }

}

import com.sun.org.apache.xpath.internal.operations.Bool;

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        File fileOut = new File("out.txt");
        InputStream inputStream = null;
        OutputStream outputStream = null;
        // try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        // try {outputStream= new FileOutputStream(fileOut);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        Integer month = in.nextInt();
        Integer day = in.nextInt();

        List<Integer> lengths = Arrays.asList(31,28,31,30,31,30,31,31,30,31,30,31);

        Integer lastDay = ((day-1) + lengths.get(month-1)) / 7 + 1;
        out.println(lastDay);

    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}

// package stupiddog;

import java.io.*;
import java.lang.*;
import java.util.*;

/**
 *
 * @author Huynh Sam Ha - BKU - VN - 1610852@hcmut.edu.vn
 * @author Stupid - Dog
 *
 */
public class StupidDog {

    public static void main(String[] args) throws IOException {
        inputSystem = new InputStreamReader(System.in);
        outputSystem = new OutputStreamWriter(System.out);
        //inputFile = new FileReader("D:/Java/File/inp.txt");
        //outputFile = new FileWriter("D:/Java/File/out.txt");

        inp = new BufferedReader(inputSystem);
        out = new PrintWriter(outputSystem);

        solve();

        inp.close();
        out.close();
    }

    static void solve() throws IOException {
        int a[] = {0,31,29,31,30,31,31,30,31,30,31,30,31};
        int m = nextInt(); int d = nextInt();
        if (a[m] == 31) {
            if (d >= 6) out.println("6");
            else out.println("5");
        }
        else if (a[m] == 30) {
            if (d == 7) out.println("6");
            else out.println("5");
        }
        else {
            out.println("5");
        }
    }

    /* ---------------------------------------------------- */
    static BufferedReader inp;
    static PrintWriter out;
    static InputStreamReader inputSystem;
    static OutputStreamWriter outputSystem;
    static Reader inputFile;
    static Writer outputFile;
    static StringTokenizer token;

    /*NSt + TAB*/
    static String nextString() throws IOException {
        while (token == null || !token.hasMoreElements()) {
            token = new StringTokenizer(inp.readLine());
        }
        return token.nextToken();
    }

    /*NI + TAB*/
    static int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    /*NL + TAB*/
    static long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    /*NDB + TAB*/
    static double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

/**
 *
 * TAB
 * out.println(); outln
 * out.printf(""); outf
 *
 */

import java.util.Scanner;

public class Contest {

	public static void main(String[] args) {

		Scanner in = new Scanner( System.in );

		int n = in.nextInt();
		int d = in.nextInt();
		if( d<7)
			System.out.println( 5 );
		else
			System.out.println( 6 );

		in.close();
	}

}

import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
        Scanner read = new Scanner(System.in);
       int a=read.nextInt();
       int b=read.nextInt();
       if (a==2){
           System.out.println(5);
       }
       else if (a==1 || a==3 || a==1 || a==5 || a==7 || a==8 || a==10 || a==12){
           if (b>5){
               System.out.println(6);
           }else {
               System.out.println(5);
           }
       }else {
           if (b>6){
               System.out.println(6);
           }else {
               System.out.println(5);
           }
       }
    }
}

import java.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Geometry {

	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	public static void main(String[] args) {
		new Geometry().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	int maxA(int[] a) {
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > max) {
				max = a[i];

			}
		}
		return max;
	}

	int minA(int[] a) {
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < a.length; i++) {
			if (a[i] < min) {
				min = a[i];

			}
		}
		return min;
	}

	void init() throws FileNotFoundException {

		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}

		tok = new StringTokenizer("");
	}

	void run() {
		try {
			long timeStart = System.currentTimeMillis();

			init();
			solve();

			out.close();

			long timeEnd = System.currentTimeMillis();
			System.err.println("Time = " + (timeEnd - timeStart) + " COMPILED");
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	long memoryTotal, memoryFree;

	void memory() {
		memoryFree = Runtime.getRuntime().freeMemory();
		System.err.println("Memory = " + ((-memoryTotal + memoryFree) >> 10) + " KB");
	}

	String readLine() throws IOException {
		return in.readLine();
	}

	String delimiter = " ";

	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}

	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}

	void sort(int[] a) {
		Integer arr[] = new Integer[a.length];
		for (int i = 0; i < a.length; i++) {
			arr[i] = a[i];
		}
		Arrays.sort(arr);
		for (int i = 0; i < a.length; i++) {
			a[i] = arr[i];
		}
	}

	void initGraph(int n) {
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<Integer>();
		}
	}

	final static int[][] STEPS = { { -1, 0 }, { 1, 0 }, { 0, 1 }, { 0, -1 } };

	boolean checkIndex(int index, int size) {
		return (0 <= index && index < size);
	}

	List<Integer>[] graph;

	void solve() throws IOException {
		int m = rI() - 1;
		int d = rI();
		int[] mes = new int[12];
		mes[0] = 31;
		mes[1] = 29;
		mes[2] = 31;
		mes[3] = 30;
		mes[4] = 31;
		mes[5] = 30;
		mes[6] = 31;
		mes[7] = 31;
		mes[8] = 30;
		mes[9] = 31;
		mes[10] = 30;
		mes[11] = 31;

		int ans = 1;
		mes[m] -= (8 - d);
		ans += mes[m] / 7;
		ans += mes[m] % 7 > 0 ? 1 : 0;
		out.println(ans);
	}
}

import java.util.*;
import java.lang.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.io.*;
public class Solution {

	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
	public int[] readIntArray(int n) {
			int[] arr = new int[n];
			for(int i=0; i<n; ++i)
				arr[i]=nextInt();
			return arr;
		}

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
	static void solve(Set<Integer> set, int[] arr, int n) {

	}
	public static void main(String args[]) {
        FastReader sc = new FastReader();
        long start = System.currentTimeMillis();

        Set<Integer> set = new HashSet<>();
        			int n = sc.nextInt();
        			int m = sc.nextInt();
        			if(n == 2) {
        				if(m == 1) {
        					System.out.println(4);
        				}
        				else {
        					System.out.println(5);
        				}
        			}
        			else {
        				if(1<=n && n <= 7) {
        					if(n%2 == 1) {
        						if(1 <= m && m <=4) {
        							System.out.println(5);
        						}else {
        							System.out.println(6);
        						}
        					}
        					else {
        						if(m == 7) {
        							System.out.println(6);
        						}
        						else {
        							System.out.println(5);
        						}
        					}
        				}
        				else {
        					if(n%2 == 0) {
        						if(1 <= m && m <=4) {
        							System.out.println(5);
        						}else {
        							System.out.println(6);
        						}
        					}
        					else {
        						if(m == 7) {
        							System.out.println(6);
        						}
        						else {
        							System.out.println(5);
        						}
        					}

        				}
        			}
        	long end = System.currentTimeMillis();
        	NumberFormat formatter = new DecimalFormat("#0.00000");
        	//System.out.print("Execution time is " + formatter.format((end - start) / 1000d) + " seconds");
        }
}

//package Div2R393;

import java.util.Scanner;

public class A {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int d = scan.nextInt();
		int odd = 7 - d + 1;
		int totalDays = 0;
		if(m == 1 || m == 5 || m == 7 || m == 8|| m == 10 || m == 12){
			totalDays = 31;
		} else if ( m == 2) {
			totalDays = 29;
		} else{
			totalDays = 30;
		}
		int ans = 1;
		ans += (totalDays - odd)/7;
		if((totalDays -odd) % 7 != 0) ans++;
		System.out.println(ans);
	}
}

import java.util.Scanner;

public class Ex {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), d = sc.nextInt(), col;
        if (m == 2) col = 29;
        else {
            if (m == 4 || m == 6 || m == 9 || m == 11) col = 30;
            else col = 31;
        }
        int pol = (col - (8 - d)) / 7, ost = (col - (8 - d)) % 7;
        System.out.println(ost == 0 ? pol + 1 : pol + 2);
    }
}

import java.util.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) {
      Scanner sc= new Scanner(System.in);
      int m=sc.nextInt();
      int d=sc.nextInt();
      int add=0,j,ans=0;
      if(m%2!=0||m==8){
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=31;j=j+7)
      		add++;
      	if(j-7<=31)
      		add++;
      }
      else{
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=30;j=j+7)
      		add++;
      	if(j-7<=30)
      		add++;
      }
      System.out.println(add);
    }
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int[] mth = {31,28,31,30,31,30,31,31,30,31,30,31};
		int m = in.nextInt();
		int day = in.nextInt();
		int ost = mth[m-1]%7;
		if(day+ost<=8){
			if((mth[m-1]+day-1)%7==0) System.out.println((mth[m-1]+day)/7);
			else {System.out.println((mth[m-1]+day)/7+1);}
		}
		else{
			if((mth[m-1]+day-1)%7==0) System.out.println(((mth[m-1]+day)/7));
			else {System.out.println((mth[m-1]+day)/7+1);}
		}
		in.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;

public class Contest{
	static Random random;
	private static void mySort(int[] s) {
        for (int i = 0; i < s.length; ++i) {
            int j = random.nextInt(i + 1);
            int t = s[i];
            s[i] = s[j];
            s[j] = t;
        }
        Arrays.sort(s);
    }

	public static void main(String[] args) {
		random = new Random(543534151132L + System.currentTimeMillis());
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int m=in.nextInt();
        int d=in.nextInt();
        int result=0;
        switch(m) {
        	case 1 : case 3: case 5: case 7: case 8: case 10: case 12:
        			result=(d+30)/7;
        			if((d+30)%7!=0)result++;
        			break;
        	case 2 :	 result=(d+27)/7;
        			 	if((d+27)%7!=0)result++;
        	default : 	result=(d+29)/7;
        				if((d+29)%7!=0)result++;
        				break;
        }
        out.println(result);
        out.close();

	}

	public static int gcd(int a, int b)
    {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
            return gcd.intValue();
    }

    public static long gcd(long a, long b)
    {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
            return gcd.longValue();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

}

import java.util.Scanner;

/**
 * Created by vadim on 10.02.2017.
 */
public class tt1 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] days = {31, 28, 31,30,31,30,31,31,30,31,30,31};
        int m = sc.nextInt();
        int d = sc.nextInt();
        int daysCount = days[m-1];
        int res = (d - 1 + daysCount) / 7 + 1;

        System.out.println(res);
    }
}

import java.util.Scanner;

public class petrCalendar {

	public static void main(String[] args)

	{

		Scanner s =new Scanner(System.in);
	//	System.out.println("Enter the month");
		int m=s.nextInt();
	//	System.out.println("enter the weekday");
		int d=s.nextInt();

		if(m<8)
		{
			if(m%2== 0)
			{
				checkdate30(d);
			}
			else
			{
				checkdate31(d);
			}
		}
		else if(m>8 && m<12)
		{
			if(m%2==0)
			{
				checkdate31(d);
			}
			else
			{
				checkdate30(d);
			}
		}
		//System.out.println("din");
	}

	private static void checkdate31(int d) {
		// TODO Auto-generated method stub

		if(d>=6 && d<=7)
		{
		System.out.println("6");

		}
		else if(d<6)
		{
			System.out.println("5");
		}
	}

	private static void checkdate30(int d) {
		// TODO Auto-generated method stub
		if(d==7)
		{
			System.out.println("6");
		}
		else if(d<7 && d>0)
		{
			System.out.println("5");
		}

	}

}

//package arhiv.c;

import java.util.Scanner;

public class Sor {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), d = sc.nextInt(), col;
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) col = 31;
        else if (m == 2) col = 29;
        else col = 30;
        int sd = col - (8 - d);
        System.out.println(sd % 7 == 0 ? sd / 7 + 1: sd / 7 + 2);
    }
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int[] mth = {31,28,31,30,31,30,31,31,30,31,30,31};
		int m = in.nextInt();
		int day = in.nextInt();
		int ost = mth[m-1]%7;
		if(day+ost<=8){System.out.println(5);}
		else{System.out.println(6);}
		in.close();
	}
}

import java.util.Objects;
import java.util.Scanner;

public class HelloWorld
{

	public static void main(String[] args)
	{

		Scanner in = new Scanner (System.in);
		int Month= in.nextInt();
		Scanner in2 = new Scanner (System.in);
		int sDay= in.nextInt();
		sDay=sDay-8;
		double dayNum = 0;
		switch(Month){
		case 1:dayNum=31;break;
		case 3:dayNum=31;break;
		case 5:dayNum=31;break;
		case 7:dayNum=31;break;
		case 8:dayNum=31;break;
		case 10:dayNum=31;break;
		case 12:dayNum=31;break;

		case 2:dayNum=28;break;

		case 4:dayNum=30;break;
		case 6:dayNum=30;break;
		case 9:dayNum=30;break;
		case 11:dayNum=30;break;
		}
		dayNum=dayNum-sDay;
		dayNum=Math.ceil(dayNum/7);
		System.out.println(dayNum);
	}

}

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String [] args){
        int month[] = new int[13];
        month[1]=31;
        month[2]=28;
        month[3]=31;
        month[4]=30;
        month[5]=31;
        month[6]=30;
        month[7]=31;
        month[8]=31;
        month[9]=30;
        month[10]=31;
        month[11]=30;
        month[12]=31;
        Scanner input = new Scanner(System.in);
        int m = input.nextInt();
        int d = input.nextInt();
        System.out.println(((8-d)+28 < month[m]) ? 6:5);
    }
}

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int mes = sc.nextInt();
        int diaIn = sc.nextInt();
        int acarr = 8-diaIn;
        int cola = (mes*31-acarr)%7;
        int res = (mes*31-acarr-cola)/7;
        System.out.println((res+1+(cola==0?0:1))/mes + (((res+1+(cola==0?0:1))% mes ==0)?0: 1)  );
    }
}

import java.util.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) {
      Scanner sc= new Scanner(System.in);
      int m=sc.nextInt();
      int d=sc.nextInt();
      int add=0,j,ans=0;
      if(m%2!=0||m==8){
      	if(d<=7){
      		ans=7-d;
      		add++;
      	}
      	for(j=2+ans+7;j<=31;j=j+7)
      		add++;
      	if(j-7<31)
      		add++;
      }
      else{
      	if(d<7){
      		d=7;
      		add++;
      	}
      	for(j=2+ans+7;j<=30;j=j+7)
      		add++;
      	if(j-7<30)
      		add++;
      }
      System.out.println(add);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class contst {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader (System.in));
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s);
		int m = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		int res = 0;
		switch(m){
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12: res = (d < 6)? 5 : 6;break;
		case 2: res = 5;break;
		default: res = (d < 7)? 5 : 6;
		}
		System.out.println(res);
	}

}

import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Created by ReaL PC on 12/6/2016.
 */
public class AAAAAA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            if (d > 5) {
                System.out.println("6");
            } else System.out.println("5");
        }
        if (m == 4 || m == 6 || m == 9 || m == 11) {
            if (d > 6) {
                System.out.println("6");
            } else System.out.println("5");
        }
        if (m == 2)
            System.out.println("5");

    }

}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by Alvin on 1/24/2017.
 */

public class Codeforces_round_393_div_2_PetrAndACalendar {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int m = input.nextInt();
        int d = input.nextInt();
        int a = 0;
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            a = 31;
        } else if (m == 2) {
            a = 29;
        } else {
            a = 30;
        }
        int answer = ((d - 1) + a - 1) / 7 + 1;
        out.println(answer);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.StringTokenizer;
//752
public class Solution{
    public static void main(String[] args)  throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(input.readLine()," ");
        int m = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        System.out.println(solve(m,d));
        input.close();
    }

    static int solve(int m, int d){
        int cols = 5; //31 days
        int day = 1;
        if(m == 2){//28 days
            cols = 4;
        }
        int ddiff = d-day;
        if(ddiff > 5){
            cols = cols+1;
        }
        if((m == 4 || m==6 || m== 9 || m == 11) && ddiff == 6){//30 days
            cols = cols-1;
        }
        return cols;
    }
}