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

public class watch_mb {
    static final int[] P;
    static {
        P = new int[31];
        for (int i = 0; i < 31; i++) {
            P[i] = 1 << i;
        }
    }
    static int MP = 7; //how much bits in main code
    static int TP = 4 * MP - 1; //how much bits in whole time code

    /** 
     * Main code:
     *
     *  --2--
     * |     |
     * 5     6
     * |     |
     *  --1--
     * |     |
     * 3     4
     * |     |
     *  --0--
     */
    static final int[] M = new int[] {
        P[0] + P[2] + P[3] + P[4] + P[5] + P[6],
        P[4] + P[6],
        P[0] + P[1] + P[2] + P[3] + P[6],
        P[0] + P[1] + P[2] + P[4] + P[6],
        P[1] + P[4] + P[5] + P[6],
        P[0] + P[1] + P[2] + P[4] + P[5],
        P[0] + P[1] + P[2] + P[3] + P[4] + P[5],
        P[2] + P[4] + P[6],
        P[0] + P[1] + P[2] + P[3] + P[4] + P[5] + P[6],
        P[0] + P[1] + P[2] + P[4] + P[5] + P[6]
    };

    /** 
     * Truncated code:
     *
     *  --2--
     *       |
     *       5
     *       |
     *  --1--
     * |     |
     * 3     4
     * |     |
     *  --0--
     */
    static final int[] TR = new int[] {
        0,
        P[4] + P[5],
        P[0] + P[1] + P[2] + P[3] + P[5],
    };

    static class Time {
        int hour;
        int minute;
        Time(int h, int m) {
            assert 0 <= h && h <= 23 : "Hour is out of bounds";
            assert 0 <= m && m <= 59 : "Minute is out of bounds";
            hour = h;
            minute = m;
        }

        void inc() {
            minute++;
            if (minute == 60) {
                minute = 0;
                hour++;
                if (hour == 24) {
                    hour = 0;
                }
            }
        }

        int totalCode() {
            int digit1 = minute % 10;
            int digit2 = minute / 10;
            int digit3 = hour % 10;
            int digit4 = hour / 10;
            return M[digit1] + ((M[digit2] + ((M[digit3] + (TR[digit4] << MP)) << MP)) << MP);
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("watch.in"));
        String input = in.readLine();
        in.close();

        assert 
            Character.isDigit(input.charAt(0)) &&
            Character.isDigit(input.charAt(1)) &&
            input.charAt(2) == ':' &&
            Character.isDigit(input.charAt(3)) &&
            Character.isDigit(input.charAt(4)) &&
            input.length() == 5 : "Input is not correct";

        int h = Integer.parseInt(input.substring(0, 2));
        int m = Integer.parseInt(input.substring(3, 5));

        Time t = new Time(h, m);
        int on = t.totalCode();
        int off = t.totalCode();
        int count = 0;
        while (on + 1 != P[TP] || off != 0) {
            count++;
            t.inc();
            on |= t.totalCode();
            off &= t.totalCode();
        }

        PrintWriter out = new PrintWriter("watch.out");
        out.println(count);
        out.close();
    }
}